From ef4791393db1ab586400d326ae7d7993e5610d00 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 7 Mar 2018 19:00:29 -0300 Subject: [PATCH 01/73] Fix overflow on math.MaxInt64 --- tools/pkgc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/pkgc.go b/tools/pkgc.go index 4b08aac5..e04017c7 100644 --- a/tools/pkgc.go +++ b/tools/pkgc.go @@ -65,7 +65,11 @@ func getConst(name string, v constant.Value) string { case constant.Int: if constant.Sign(v) >= 0 { if i, exact := constant.Uint64Val(v); exact { - if i > math.MaxInt64 { + if i < math.MaxInt8 { + format = "uint(%s)" + } else if i < math.MaxInt32 { + format = "uint32(%s)" + } else { format = "uint64(%s)" } } else { From 4f3cc3ed446170a161cf8ecb644a740ac233b005 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 7 Mar 2018 19:30:45 -0300 Subject: [PATCH 02/73] Fix int underflow on 32bit CPUs --- tools/pkgc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/pkgc.go b/tools/pkgc.go index e04017c7..93a6fe7d 100644 --- a/tools/pkgc.go +++ b/tools/pkgc.go @@ -75,6 +75,16 @@ func getConst(name string, v constant.Value) string { } else { format = "float64(%s)" } + } else { + if i, exact := constant.Int64Val(v); exact { + if i > math.MinInt8 { + format = "int(%s)" + } else if i > math.MinInt32 { + format = "int32(%s)" + } else { + format = "int64(%s)" + } + } } case constant.Float: format = "float64(%s)" From 4a74f69cf4627f8ec502a032386620e837b9c2e4 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 12:05:26 -0300 Subject: [PATCH 03/73] Preparing to split the parts --- Makefile => grumpy-runtime-src/Makefile | 0 __init__.py => grumpy-runtime-src/__init__.py | 0 .../benchmarks}/bm_call_method.py | 0 .../benchmarks}/bm_call_simple.py | 0 .../benchmarks}/call.py | 0 .../benchmarks}/comprehension.py | 0 .../benchmarks}/concurrent.py | 0 .../benchmarks}/dict.py | 0 .../benchmarks}/generator.py | 0 .../benchmarks}/list.py | 0 .../benchmarks}/loop.py | 0 .../benchmarks}/tuple.py | 0 .../compiler}/__init__.py | 0 .../compiler}/block.py | 0 .../compiler}/block_test.py | 0 .../compiler}/expr.py | 0 .../compiler}/expr_visitor.py | 0 .../compiler}/expr_visitor_test.py | 0 .../compiler}/imputil.py | 0 .../compiler}/imputil_test.py | 0 .../compiler}/shard_test.py | 0 .../compiler}/stmt.py | 0 .../compiler}/stmt_test.py | 0 .../compiler}/util.py | 0 .../compiler}/util_test.py | 0 {lib => grumpy-runtime-src/lib}/README.md | 0 .../lib}/__builtin__.py | 0 {lib => grumpy-runtime-src/lib}/_random.py | 0 {lib => grumpy-runtime-src/lib}/_syscall.py | 0 {lib => grumpy-runtime-src/lib}/cStringIO.py | 0 {lib => grumpy-runtime-src/lib}/errno.py | 0 {lib => grumpy-runtime-src/lib}/exceptions.py | 0 {lib => grumpy-runtime-src/lib}/itertools.py | 0 .../lib}/itertools_test.py | 0 {lib => grumpy-runtime-src/lib}/math.py | 0 {lib => grumpy-runtime-src/lib}/math_test.py | 0 .../lib}/os/__init__.py | 0 {lib => grumpy-runtime-src/lib}/os/path.py | 0 .../lib}/os/path_test.py | 0 {lib => grumpy-runtime-src/lib}/os_test.py | 0 .../lib}/random_test.py | 0 {lib => grumpy-runtime-src/lib}/select_.py | 0 {lib => grumpy-runtime-src/lib}/stat.py | 0 {lib => grumpy-runtime-src/lib}/sys.py | 0 {lib => grumpy-runtime-src/lib}/sys_test.py | 0 {lib => grumpy-runtime-src/lib}/tempfile.py | 0 .../lib}/tempfile_test.py | 0 {lib => grumpy-runtime-src/lib}/thread.py | 0 {lib => grumpy-runtime-src/lib}/time.py | 0 {lib => grumpy-runtime-src/lib}/time_test.py | 0 {lib => grumpy-runtime-src/lib}/types_test.py | 0 {lib => grumpy-runtime-src/lib}/weetest.py | 0 .../lib}/weetest_test.py | 0 .../runtime}/baseexception.go | 0 .../runtime}/baseexception_test.go | 0 .../runtime}/basestring.go | 0 .../runtime}/basestring_test.go | 0 .../runtime}/bool.go | 0 .../runtime}/bool_test.go | 0 .../runtime}/builtin_types.go | 0 .../runtime}/builtin_types_test.go | 0 .../runtime}/bytearray.go | 0 .../runtime}/bytearray_test.go | 0 .../runtime}/code.go | 0 .../runtime}/code_test.go | 0 .../runtime}/complex.go | 0 .../runtime}/complex_test.go | 0 .../runtime}/core.go | 0 .../runtime}/core_test.go | 0 .../runtime}/descriptor.go | 0 .../runtime}/descriptor_test.go | 0 .../runtime}/dict.go | 0 .../runtime}/dict_test.go | 0 .../runtime}/doc.go | 0 .../runtime}/exceptions.go | 0 .../runtime}/file.go | 0 .../runtime}/file_test.go | 0 .../runtime}/float.go | 0 .../runtime}/float_test.go | 0 .../runtime}/frame.go | 0 .../runtime}/frame_test.go | 0 .../runtime}/function.go | 0 .../runtime}/function_test.go | 0 .../runtime}/generator.go | 0 .../runtime}/generator_test.go | 0 .../runtime}/int.go | 0 .../runtime}/int_test.go | 0 .../runtime}/list.go | 0 .../runtime}/list_test.go | 0 .../runtime}/long.go | 0 .../runtime}/long_test.go | 0 .../runtime}/method.go | 0 .../runtime}/method_test.go | 0 .../runtime}/module.go | 0 .../runtime}/module_test.go | 0 .../runtime}/native.go | 0 .../runtime}/native_test.go | 0 .../runtime}/numeric.go | 0 .../runtime}/object.go | 0 .../runtime}/object_test.go | 0 .../runtime}/param.go | 0 .../runtime}/param_test.go | 0 .../runtime}/range.go | 0 .../runtime}/range_test.go | 0 .../runtime}/seq.go | 0 .../runtime}/seq_test.go | 0 .../runtime}/set.go | 0 .../runtime}/set_test.go | 0 .../runtime}/slice.go | 0 .../runtime}/slice_test.go | 0 .../runtime}/slots.go | 0 .../runtime}/slots_test.go | 0 .../runtime}/str.go | 0 .../runtime}/str_test.go | 0 .../runtime}/super.go | 0 .../runtime}/super_test.go | 0 .../runtime}/threading.go | 0 .../runtime}/threading_test.go | 0 .../runtime}/traceback.go | 0 .../runtime}/tuple.go | 0 .../runtime}/tuple_test.go | 0 .../runtime}/type.go | 0 .../runtime}/type_test.go | 0 .../runtime}/unicode.go | 0 .../runtime}/unicode_test.go | 0 .../runtime}/weakref.go | 0 .../runtime}/weakref_test.go | 0 .../testing}/assert_test.py | 0 .../testing}/assign_test.py | 0 .../testing}/builtin_test.py | 0 .../testing}/class_test.py | 0 .../testing}/compare_test.py | 0 .../testing}/complex_test.py | 0 .../testing}/comprehension_test.py | 0 .../testing}/dict_test.py | 0 .../testing}/file_test.py | 0 .../testing}/float_test.py | 0 .../testing}/for_test.py | 0 .../testing}/function_test.py | 0 .../testing}/generator_test.py | 0 .../testing}/getopt_test.py | 0 .../testing}/global_test.py | 0 .../testing}/if_test.py | 0 .../testing}/import_test.py | 0 .../testing}/list_test.py | 0 .../testing}/native_test.py | 0 .../testing}/op_test.py | 0 .../testing}/pow_test.py | 0 .../testing}/scope_test.py | 0 .../testing}/str_test.py | 0 .../testing}/struct_test.py | 0 .../testing}/try_test.py | 0 .../testing}/tuple_test.py | 0 .../testing}/while_test.py | 0 .../testing}/with_test.py | 0 .../third_party}/ouroboros/AUTHORS | 0 .../third_party}/ouroboros/LICENSE | 0 .../third_party}/ouroboros/READEME.md | 0 .../third_party}/ouroboros/operator.py | 0 .../ouroboros/test/test_operator.py | 0 .../third_party}/pypy/LICENSE | 0 .../third_party}/pypy/README.md | 0 .../third_party}/pypy/_collections.py | 0 .../third_party}/pypy/_csv.py | 0 .../third_party}/pypy/_functools.py | 0 .../third_party}/pypy/_md5.py | 0 .../third_party}/pypy/_sha.py | 0 .../third_party}/pypy/_sha256.py | 0 .../third_party}/pypy/_sha512.py | 0 .../third_party}/pypy/_sre.py | 0 .../third_party}/pypy/_struct.py | 0 .../third_party}/pypy/binascii.py | 0 .../third_party}/pypy/datetime.py | 0 .../third_party}/pythonparser/LICENSE.txt | 0 .../third_party}/pythonparser/README.md | 0 .../third_party}/pythonparser/__init__.py | 0 .../third_party}/pythonparser/algorithm.py | 0 .../third_party}/pythonparser/ast.py | 0 .../third_party}/pythonparser/diagnostic.py | 0 .../third_party}/pythonparser/lexer.py | 0 .../third_party}/pythonparser/parser.py | 0 .../third_party}/pythonparser/source.py | 0 .../third_party}/stdlib/LICENSE | 0 .../third_party}/stdlib/Queue.py | 0 .../third_party}/stdlib/README.md | 0 .../third_party}/stdlib/StringIO.py | 0 .../third_party}/stdlib/UserDict.py | 0 .../third_party}/stdlib/UserList.py | 0 .../third_party}/stdlib/UserString.py | 0 .../third_party}/stdlib/_abcoll.py | 0 .../third_party}/stdlib/_weakrefset.py | 0 .../third_party}/stdlib/abc.py | 0 .../third_party}/stdlib/argparse.py | 0 .../third_party}/stdlib/base64.py | 0 .../third_party}/stdlib/bisect.py | 0 .../third_party}/stdlib/collections.py | 0 .../third_party}/stdlib/colorsys.py | 0 .../third_party}/stdlib/contextlib.py | 0 .../third_party}/stdlib/copy.py | 0 .../third_party}/stdlib/copy_reg.py | 0 .../third_party}/stdlib/csv.py | 0 .../third_party}/stdlib/difflib.py | 0 .../third_party}/stdlib/dircache.py | 0 .../third_party}/stdlib/dummy_thread.py | 0 .../third_party}/stdlib/fnmatch.py | 0 .../third_party}/stdlib/fpformat.py | 0 .../third_party}/stdlib/functools.py | 0 .../third_party}/stdlib/genericpath.py | 0 .../third_party}/stdlib/getopt.py | 0 .../third_party}/stdlib/glob.py | 0 .../third_party}/stdlib/heapq.py | 0 .../third_party}/stdlib/json/__init__.py | 0 .../third_party}/stdlib/json/decoder.py | 0 .../third_party}/stdlib/json/encoder.py | 0 .../third_party}/stdlib/json_scanner.py | 0 .../third_party}/stdlib/keyword.py | 0 .../third_party}/stdlib/linecache.py | 0 .../third_party}/stdlib/md5.py | 0 .../third_party}/stdlib/mimetools.py | 0 .../third_party}/stdlib/mutex.py | 0 .../third_party}/stdlib/optparse.py | 0 .../third_party}/stdlib/pprint.py | 0 .../third_party}/stdlib/quopri.py | 0 .../third_party}/stdlib/random.py | 0 .../third_party}/stdlib/re.py | 0 .../third_party}/stdlib/re_tests.py | 0 .../third_party}/stdlib/repr.py | 0 .../third_party}/stdlib/rfc822.py | 0 .../third_party}/stdlib/sched.py | 0 .../third_party}/stdlib/sha.py | 0 .../third_party}/stdlib/sre_compile.py | 0 .../third_party}/stdlib/sre_constants.py | 0 .../third_party}/stdlib/sre_parse.py | 0 .../third_party}/stdlib/string.py | 0 .../third_party}/stdlib/test/__init__.py | 0 .../third_party}/stdlib/test/list_tests.py | 0 .../third_party}/stdlib/test/lock_tests.py | 0 .../third_party}/stdlib/test/mapping_tests.py | 0 .../third_party}/stdlib/test/seq_tests.py | 0 .../third_party}/stdlib/test/string_tests.py | 0 .../third_party}/stdlib/test/test_argparse.py | 0 .../third_party}/stdlib/test/test_bisect.py | 0 .../third_party}/stdlib/test/test_colorsys.py | 0 .../third_party}/stdlib/test/test_datetime.py | 0 .../third_party}/stdlib/test/test_dict.py | 0 .../third_party}/stdlib/test/test_dircache.py | 0 .../stdlib/test/test_dummy_thread.py | 0 .../third_party}/stdlib/test/test_fpformat.py | 0 .../stdlib/test/test_genericpath.py | 0 .../third_party}/stdlib/test/test_list.py | 0 .../third_party}/stdlib/test/test_md5.py | 0 .../stdlib/test/test_mimetools.py | 0 .../third_party}/stdlib/test/test_mutex.py | 0 .../third_party}/stdlib/test/test_queue.py | 0 .../third_party}/stdlib/test/test_quopri.py | 0 .../third_party}/stdlib/test/test_rfc822.py | 0 .../third_party}/stdlib/test/test_sched.py | 0 .../third_party}/stdlib/test/test_select.py | 0 .../third_party}/stdlib/test/test_slice.py | 0 .../third_party}/stdlib/test/test_stat.py | 0 .../third_party}/stdlib/test/test_string.py | 0 .../third_party}/stdlib/test/test_support.py | 0 .../stdlib/test/test_threading.py | 0 .../third_party}/stdlib/test/test_tuple.py | 0 .../third_party}/stdlib/test/test_uu.py | 0 .../third_party}/stdlib/textwrap.py | 0 .../third_party}/stdlib/threading.py | 0 .../third_party}/stdlib/traceback.py | 0 .../third_party}/stdlib/types.py | 0 .../third_party}/stdlib/unittest/__init__.py | 0 .../third_party}/stdlib/unittest_case.py | 0 .../third_party}/stdlib/unittest_loader.py | 0 .../third_party}/stdlib/unittest_result.py | 0 .../third_party}/stdlib/unittest_runner.py | 0 .../third_party}/stdlib/unittest_signals.py | 0 .../third_party}/stdlib/unittest_suite.py | 0 .../third_party}/stdlib/unittest_util.py | 0 .../third_party}/stdlib/urlparse.py | 0 .../third_party}/stdlib/uu.py | 0 .../third_party}/stdlib/warnings.py | 0 .../third_party}/stdlib/weakref.py | 0 {tools => grumpy-runtime-src/tools}/benchcmp | 0 .../tools}/coverparse | 0 {tools => grumpy-runtime-src/tools}/diffrange | 0 {tools => grumpy-runtime-src/tools}/genmake | 0 {tools => grumpy-runtime-src/tools}/grumpc | 0 {tools => grumpy-runtime-src/tools}/grumprun | 0 {tools => grumpy-runtime-src/tools}/pkgc.go | 0 {tools => grumpy-runtime-src/tools}/pydeps | 0 setup.py | 78 +++++++++++++++++++ 290 files changed, 78 insertions(+) rename Makefile => grumpy-runtime-src/Makefile (100%) rename __init__.py => grumpy-runtime-src/__init__.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/bm_call_method.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/bm_call_simple.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/call.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/comprehension.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/concurrent.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/dict.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/generator.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/list.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/loop.py (100%) rename {benchmarks => grumpy-runtime-src/benchmarks}/tuple.py (100%) rename {compiler => grumpy-runtime-src/compiler}/__init__.py (100%) rename {compiler => grumpy-runtime-src/compiler}/block.py (100%) rename {compiler => grumpy-runtime-src/compiler}/block_test.py (100%) rename {compiler => grumpy-runtime-src/compiler}/expr.py (100%) rename {compiler => grumpy-runtime-src/compiler}/expr_visitor.py (100%) rename {compiler => grumpy-runtime-src/compiler}/expr_visitor_test.py (100%) rename {compiler => grumpy-runtime-src/compiler}/imputil.py (100%) rename {compiler => grumpy-runtime-src/compiler}/imputil_test.py (100%) rename {compiler => grumpy-runtime-src/compiler}/shard_test.py (100%) rename {compiler => grumpy-runtime-src/compiler}/stmt.py (100%) rename {compiler => grumpy-runtime-src/compiler}/stmt_test.py (100%) rename {compiler => grumpy-runtime-src/compiler}/util.py (100%) rename {compiler => grumpy-runtime-src/compiler}/util_test.py (100%) rename {lib => grumpy-runtime-src/lib}/README.md (100%) rename {lib => grumpy-runtime-src/lib}/__builtin__.py (100%) rename {lib => grumpy-runtime-src/lib}/_random.py (100%) rename {lib => grumpy-runtime-src/lib}/_syscall.py (100%) rename {lib => grumpy-runtime-src/lib}/cStringIO.py (100%) rename {lib => grumpy-runtime-src/lib}/errno.py (100%) rename {lib => grumpy-runtime-src/lib}/exceptions.py (100%) rename {lib => grumpy-runtime-src/lib}/itertools.py (100%) rename {lib => grumpy-runtime-src/lib}/itertools_test.py (100%) rename {lib => grumpy-runtime-src/lib}/math.py (100%) rename {lib => grumpy-runtime-src/lib}/math_test.py (100%) rename {lib => grumpy-runtime-src/lib}/os/__init__.py (100%) rename {lib => grumpy-runtime-src/lib}/os/path.py (100%) rename {lib => grumpy-runtime-src/lib}/os/path_test.py (100%) rename {lib => grumpy-runtime-src/lib}/os_test.py (100%) rename {lib => grumpy-runtime-src/lib}/random_test.py (100%) rename {lib => grumpy-runtime-src/lib}/select_.py (100%) rename {lib => grumpy-runtime-src/lib}/stat.py (100%) rename {lib => grumpy-runtime-src/lib}/sys.py (100%) rename {lib => grumpy-runtime-src/lib}/sys_test.py (100%) rename {lib => grumpy-runtime-src/lib}/tempfile.py (100%) rename {lib => grumpy-runtime-src/lib}/tempfile_test.py (100%) rename {lib => grumpy-runtime-src/lib}/thread.py (100%) rename {lib => grumpy-runtime-src/lib}/time.py (100%) rename {lib => grumpy-runtime-src/lib}/time_test.py (100%) rename {lib => grumpy-runtime-src/lib}/types_test.py (100%) rename {lib => grumpy-runtime-src/lib}/weetest.py (100%) rename {lib => grumpy-runtime-src/lib}/weetest_test.py (100%) rename {runtime => grumpy-runtime-src/runtime}/baseexception.go (100%) rename {runtime => grumpy-runtime-src/runtime}/baseexception_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/basestring.go (100%) rename {runtime => grumpy-runtime-src/runtime}/basestring_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/bool.go (100%) rename {runtime => grumpy-runtime-src/runtime}/bool_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/builtin_types.go (100%) rename {runtime => grumpy-runtime-src/runtime}/builtin_types_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/bytearray.go (100%) rename {runtime => grumpy-runtime-src/runtime}/bytearray_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/code.go (100%) rename {runtime => grumpy-runtime-src/runtime}/code_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/complex.go (100%) rename {runtime => grumpy-runtime-src/runtime}/complex_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/core.go (100%) rename {runtime => grumpy-runtime-src/runtime}/core_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/descriptor.go (100%) rename {runtime => grumpy-runtime-src/runtime}/descriptor_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/dict.go (100%) rename {runtime => grumpy-runtime-src/runtime}/dict_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/doc.go (100%) rename {runtime => grumpy-runtime-src/runtime}/exceptions.go (100%) rename {runtime => grumpy-runtime-src/runtime}/file.go (100%) rename {runtime => grumpy-runtime-src/runtime}/file_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/float.go (100%) rename {runtime => grumpy-runtime-src/runtime}/float_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/frame.go (100%) rename {runtime => grumpy-runtime-src/runtime}/frame_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/function.go (100%) rename {runtime => grumpy-runtime-src/runtime}/function_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/generator.go (100%) rename {runtime => grumpy-runtime-src/runtime}/generator_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/int.go (100%) rename {runtime => grumpy-runtime-src/runtime}/int_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/list.go (100%) rename {runtime => grumpy-runtime-src/runtime}/list_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/long.go (100%) rename {runtime => grumpy-runtime-src/runtime}/long_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/method.go (100%) rename {runtime => grumpy-runtime-src/runtime}/method_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/module.go (100%) rename {runtime => grumpy-runtime-src/runtime}/module_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/native.go (100%) rename {runtime => grumpy-runtime-src/runtime}/native_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/numeric.go (100%) rename {runtime => grumpy-runtime-src/runtime}/object.go (100%) rename {runtime => grumpy-runtime-src/runtime}/object_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/param.go (100%) rename {runtime => grumpy-runtime-src/runtime}/param_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/range.go (100%) rename {runtime => grumpy-runtime-src/runtime}/range_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/seq.go (100%) rename {runtime => grumpy-runtime-src/runtime}/seq_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/set.go (100%) rename {runtime => grumpy-runtime-src/runtime}/set_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/slice.go (100%) rename {runtime => grumpy-runtime-src/runtime}/slice_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/slots.go (100%) rename {runtime => grumpy-runtime-src/runtime}/slots_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/str.go (100%) rename {runtime => grumpy-runtime-src/runtime}/str_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/super.go (100%) rename {runtime => grumpy-runtime-src/runtime}/super_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/threading.go (100%) rename {runtime => grumpy-runtime-src/runtime}/threading_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/traceback.go (100%) rename {runtime => grumpy-runtime-src/runtime}/tuple.go (100%) rename {runtime => grumpy-runtime-src/runtime}/tuple_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/type.go (100%) rename {runtime => grumpy-runtime-src/runtime}/type_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/unicode.go (100%) rename {runtime => grumpy-runtime-src/runtime}/unicode_test.go (100%) rename {runtime => grumpy-runtime-src/runtime}/weakref.go (100%) rename {runtime => grumpy-runtime-src/runtime}/weakref_test.go (100%) rename {testing => grumpy-runtime-src/testing}/assert_test.py (100%) rename {testing => grumpy-runtime-src/testing}/assign_test.py (100%) rename {testing => grumpy-runtime-src/testing}/builtin_test.py (100%) rename {testing => grumpy-runtime-src/testing}/class_test.py (100%) rename {testing => grumpy-runtime-src/testing}/compare_test.py (100%) rename {testing => grumpy-runtime-src/testing}/complex_test.py (100%) rename {testing => grumpy-runtime-src/testing}/comprehension_test.py (100%) rename {testing => grumpy-runtime-src/testing}/dict_test.py (100%) rename {testing => grumpy-runtime-src/testing}/file_test.py (100%) rename {testing => grumpy-runtime-src/testing}/float_test.py (100%) rename {testing => grumpy-runtime-src/testing}/for_test.py (100%) rename {testing => grumpy-runtime-src/testing}/function_test.py (100%) rename {testing => grumpy-runtime-src/testing}/generator_test.py (100%) rename {testing => grumpy-runtime-src/testing}/getopt_test.py (100%) rename {testing => grumpy-runtime-src/testing}/global_test.py (100%) rename {testing => grumpy-runtime-src/testing}/if_test.py (100%) rename {testing => grumpy-runtime-src/testing}/import_test.py (100%) rename {testing => grumpy-runtime-src/testing}/list_test.py (100%) rename {testing => grumpy-runtime-src/testing}/native_test.py (100%) rename {testing => grumpy-runtime-src/testing}/op_test.py (100%) rename {testing => grumpy-runtime-src/testing}/pow_test.py (100%) rename {testing => grumpy-runtime-src/testing}/scope_test.py (100%) rename {testing => grumpy-runtime-src/testing}/str_test.py (100%) rename {testing => grumpy-runtime-src/testing}/struct_test.py (100%) rename {testing => grumpy-runtime-src/testing}/try_test.py (100%) rename {testing => grumpy-runtime-src/testing}/tuple_test.py (100%) rename {testing => grumpy-runtime-src/testing}/while_test.py (100%) rename {testing => grumpy-runtime-src/testing}/with_test.py (100%) rename {third_party => grumpy-runtime-src/third_party}/ouroboros/AUTHORS (100%) rename {third_party => grumpy-runtime-src/third_party}/ouroboros/LICENSE (100%) rename {third_party => grumpy-runtime-src/third_party}/ouroboros/READEME.md (100%) rename {third_party => grumpy-runtime-src/third_party}/ouroboros/operator.py (100%) rename {third_party => grumpy-runtime-src/third_party}/ouroboros/test/test_operator.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/LICENSE (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/README.md (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_collections.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_csv.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_functools.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_md5.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_sha.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_sha256.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_sha512.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_sre.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/_struct.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/binascii.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pypy/datetime.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/LICENSE.txt (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/README.md (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/__init__.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/algorithm.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/ast.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/diagnostic.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/lexer.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/parser.py (100%) rename {third_party => grumpy-runtime-src/third_party}/pythonparser/source.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/LICENSE (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/Queue.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/README.md (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/StringIO.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/UserDict.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/UserList.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/UserString.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/_abcoll.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/_weakrefset.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/abc.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/argparse.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/base64.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/bisect.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/collections.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/colorsys.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/contextlib.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/copy.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/copy_reg.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/csv.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/difflib.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/dircache.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/dummy_thread.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/fnmatch.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/fpformat.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/functools.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/genericpath.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/getopt.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/glob.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/heapq.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/json/__init__.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/json/decoder.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/json/encoder.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/json_scanner.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/keyword.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/linecache.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/md5.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/mimetools.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/mutex.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/optparse.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/pprint.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/quopri.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/random.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/re.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/re_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/repr.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/rfc822.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/sched.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/sha.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/sre_compile.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/sre_constants.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/sre_parse.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/string.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/__init__.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/list_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/lock_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/mapping_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/seq_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/string_tests.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_argparse.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_bisect.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_colorsys.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_datetime.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_dict.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_dircache.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_dummy_thread.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_fpformat.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_genericpath.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_list.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_md5.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_mimetools.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_mutex.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_queue.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_quopri.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_rfc822.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_sched.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_select.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_slice.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_stat.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_string.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_support.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_threading.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_tuple.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/test/test_uu.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/textwrap.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/threading.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/traceback.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/types.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest/__init__.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_case.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_loader.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_result.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_runner.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_signals.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_suite.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/unittest_util.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/urlparse.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/uu.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/warnings.py (100%) rename {third_party => grumpy-runtime-src/third_party}/stdlib/weakref.py (100%) rename {tools => grumpy-runtime-src/tools}/benchcmp (100%) rename {tools => grumpy-runtime-src/tools}/coverparse (100%) rename {tools => grumpy-runtime-src/tools}/diffrange (100%) rename {tools => grumpy-runtime-src/tools}/genmake (100%) rename {tools => grumpy-runtime-src/tools}/grumpc (100%) rename {tools => grumpy-runtime-src/tools}/grumprun (100%) rename {tools => grumpy-runtime-src/tools}/pkgc.go (100%) rename {tools => grumpy-runtime-src/tools}/pydeps (100%) create mode 100644 setup.py diff --git a/Makefile b/grumpy-runtime-src/Makefile similarity index 100% rename from Makefile rename to grumpy-runtime-src/Makefile diff --git a/__init__.py b/grumpy-runtime-src/__init__.py similarity index 100% rename from __init__.py rename to grumpy-runtime-src/__init__.py diff --git a/benchmarks/bm_call_method.py b/grumpy-runtime-src/benchmarks/bm_call_method.py similarity index 100% rename from benchmarks/bm_call_method.py rename to grumpy-runtime-src/benchmarks/bm_call_method.py diff --git a/benchmarks/bm_call_simple.py b/grumpy-runtime-src/benchmarks/bm_call_simple.py similarity index 100% rename from benchmarks/bm_call_simple.py rename to grumpy-runtime-src/benchmarks/bm_call_simple.py diff --git a/benchmarks/call.py b/grumpy-runtime-src/benchmarks/call.py similarity index 100% rename from benchmarks/call.py rename to grumpy-runtime-src/benchmarks/call.py diff --git a/benchmarks/comprehension.py b/grumpy-runtime-src/benchmarks/comprehension.py similarity index 100% rename from benchmarks/comprehension.py rename to grumpy-runtime-src/benchmarks/comprehension.py diff --git a/benchmarks/concurrent.py b/grumpy-runtime-src/benchmarks/concurrent.py similarity index 100% rename from benchmarks/concurrent.py rename to grumpy-runtime-src/benchmarks/concurrent.py diff --git a/benchmarks/dict.py b/grumpy-runtime-src/benchmarks/dict.py similarity index 100% rename from benchmarks/dict.py rename to grumpy-runtime-src/benchmarks/dict.py diff --git a/benchmarks/generator.py b/grumpy-runtime-src/benchmarks/generator.py similarity index 100% rename from benchmarks/generator.py rename to grumpy-runtime-src/benchmarks/generator.py diff --git a/benchmarks/list.py b/grumpy-runtime-src/benchmarks/list.py similarity index 100% rename from benchmarks/list.py rename to grumpy-runtime-src/benchmarks/list.py diff --git a/benchmarks/loop.py b/grumpy-runtime-src/benchmarks/loop.py similarity index 100% rename from benchmarks/loop.py rename to grumpy-runtime-src/benchmarks/loop.py diff --git a/benchmarks/tuple.py b/grumpy-runtime-src/benchmarks/tuple.py similarity index 100% rename from benchmarks/tuple.py rename to grumpy-runtime-src/benchmarks/tuple.py diff --git a/compiler/__init__.py b/grumpy-runtime-src/compiler/__init__.py similarity index 100% rename from compiler/__init__.py rename to grumpy-runtime-src/compiler/__init__.py diff --git a/compiler/block.py b/grumpy-runtime-src/compiler/block.py similarity index 100% rename from compiler/block.py rename to grumpy-runtime-src/compiler/block.py diff --git a/compiler/block_test.py b/grumpy-runtime-src/compiler/block_test.py similarity index 100% rename from compiler/block_test.py rename to grumpy-runtime-src/compiler/block_test.py diff --git a/compiler/expr.py b/grumpy-runtime-src/compiler/expr.py similarity index 100% rename from compiler/expr.py rename to grumpy-runtime-src/compiler/expr.py diff --git a/compiler/expr_visitor.py b/grumpy-runtime-src/compiler/expr_visitor.py similarity index 100% rename from compiler/expr_visitor.py rename to grumpy-runtime-src/compiler/expr_visitor.py diff --git a/compiler/expr_visitor_test.py b/grumpy-runtime-src/compiler/expr_visitor_test.py similarity index 100% rename from compiler/expr_visitor_test.py rename to grumpy-runtime-src/compiler/expr_visitor_test.py diff --git a/compiler/imputil.py b/grumpy-runtime-src/compiler/imputil.py similarity index 100% rename from compiler/imputil.py rename to grumpy-runtime-src/compiler/imputil.py diff --git a/compiler/imputil_test.py b/grumpy-runtime-src/compiler/imputil_test.py similarity index 100% rename from compiler/imputil_test.py rename to grumpy-runtime-src/compiler/imputil_test.py diff --git a/compiler/shard_test.py b/grumpy-runtime-src/compiler/shard_test.py similarity index 100% rename from compiler/shard_test.py rename to grumpy-runtime-src/compiler/shard_test.py diff --git a/compiler/stmt.py b/grumpy-runtime-src/compiler/stmt.py similarity index 100% rename from compiler/stmt.py rename to grumpy-runtime-src/compiler/stmt.py diff --git a/compiler/stmt_test.py b/grumpy-runtime-src/compiler/stmt_test.py similarity index 100% rename from compiler/stmt_test.py rename to grumpy-runtime-src/compiler/stmt_test.py diff --git a/compiler/util.py b/grumpy-runtime-src/compiler/util.py similarity index 100% rename from compiler/util.py rename to grumpy-runtime-src/compiler/util.py diff --git a/compiler/util_test.py b/grumpy-runtime-src/compiler/util_test.py similarity index 100% rename from compiler/util_test.py rename to grumpy-runtime-src/compiler/util_test.py diff --git a/lib/README.md b/grumpy-runtime-src/lib/README.md similarity index 100% rename from lib/README.md rename to grumpy-runtime-src/lib/README.md diff --git a/lib/__builtin__.py b/grumpy-runtime-src/lib/__builtin__.py similarity index 100% rename from lib/__builtin__.py rename to grumpy-runtime-src/lib/__builtin__.py diff --git a/lib/_random.py b/grumpy-runtime-src/lib/_random.py similarity index 100% rename from lib/_random.py rename to grumpy-runtime-src/lib/_random.py diff --git a/lib/_syscall.py b/grumpy-runtime-src/lib/_syscall.py similarity index 100% rename from lib/_syscall.py rename to grumpy-runtime-src/lib/_syscall.py diff --git a/lib/cStringIO.py b/grumpy-runtime-src/lib/cStringIO.py similarity index 100% rename from lib/cStringIO.py rename to grumpy-runtime-src/lib/cStringIO.py diff --git a/lib/errno.py b/grumpy-runtime-src/lib/errno.py similarity index 100% rename from lib/errno.py rename to grumpy-runtime-src/lib/errno.py diff --git a/lib/exceptions.py b/grumpy-runtime-src/lib/exceptions.py similarity index 100% rename from lib/exceptions.py rename to grumpy-runtime-src/lib/exceptions.py diff --git a/lib/itertools.py b/grumpy-runtime-src/lib/itertools.py similarity index 100% rename from lib/itertools.py rename to grumpy-runtime-src/lib/itertools.py diff --git a/lib/itertools_test.py b/grumpy-runtime-src/lib/itertools_test.py similarity index 100% rename from lib/itertools_test.py rename to grumpy-runtime-src/lib/itertools_test.py diff --git a/lib/math.py b/grumpy-runtime-src/lib/math.py similarity index 100% rename from lib/math.py rename to grumpy-runtime-src/lib/math.py diff --git a/lib/math_test.py b/grumpy-runtime-src/lib/math_test.py similarity index 100% rename from lib/math_test.py rename to grumpy-runtime-src/lib/math_test.py diff --git a/lib/os/__init__.py b/grumpy-runtime-src/lib/os/__init__.py similarity index 100% rename from lib/os/__init__.py rename to grumpy-runtime-src/lib/os/__init__.py diff --git a/lib/os/path.py b/grumpy-runtime-src/lib/os/path.py similarity index 100% rename from lib/os/path.py rename to grumpy-runtime-src/lib/os/path.py diff --git a/lib/os/path_test.py b/grumpy-runtime-src/lib/os/path_test.py similarity index 100% rename from lib/os/path_test.py rename to grumpy-runtime-src/lib/os/path_test.py diff --git a/lib/os_test.py b/grumpy-runtime-src/lib/os_test.py similarity index 100% rename from lib/os_test.py rename to grumpy-runtime-src/lib/os_test.py diff --git a/lib/random_test.py b/grumpy-runtime-src/lib/random_test.py similarity index 100% rename from lib/random_test.py rename to grumpy-runtime-src/lib/random_test.py diff --git a/lib/select_.py b/grumpy-runtime-src/lib/select_.py similarity index 100% rename from lib/select_.py rename to grumpy-runtime-src/lib/select_.py diff --git a/lib/stat.py b/grumpy-runtime-src/lib/stat.py similarity index 100% rename from lib/stat.py rename to grumpy-runtime-src/lib/stat.py diff --git a/lib/sys.py b/grumpy-runtime-src/lib/sys.py similarity index 100% rename from lib/sys.py rename to grumpy-runtime-src/lib/sys.py diff --git a/lib/sys_test.py b/grumpy-runtime-src/lib/sys_test.py similarity index 100% rename from lib/sys_test.py rename to grumpy-runtime-src/lib/sys_test.py diff --git a/lib/tempfile.py b/grumpy-runtime-src/lib/tempfile.py similarity index 100% rename from lib/tempfile.py rename to grumpy-runtime-src/lib/tempfile.py diff --git a/lib/tempfile_test.py b/grumpy-runtime-src/lib/tempfile_test.py similarity index 100% rename from lib/tempfile_test.py rename to grumpy-runtime-src/lib/tempfile_test.py diff --git a/lib/thread.py b/grumpy-runtime-src/lib/thread.py similarity index 100% rename from lib/thread.py rename to grumpy-runtime-src/lib/thread.py diff --git a/lib/time.py b/grumpy-runtime-src/lib/time.py similarity index 100% rename from lib/time.py rename to grumpy-runtime-src/lib/time.py diff --git a/lib/time_test.py b/grumpy-runtime-src/lib/time_test.py similarity index 100% rename from lib/time_test.py rename to grumpy-runtime-src/lib/time_test.py diff --git a/lib/types_test.py b/grumpy-runtime-src/lib/types_test.py similarity index 100% rename from lib/types_test.py rename to grumpy-runtime-src/lib/types_test.py diff --git a/lib/weetest.py b/grumpy-runtime-src/lib/weetest.py similarity index 100% rename from lib/weetest.py rename to grumpy-runtime-src/lib/weetest.py diff --git a/lib/weetest_test.py b/grumpy-runtime-src/lib/weetest_test.py similarity index 100% rename from lib/weetest_test.py rename to grumpy-runtime-src/lib/weetest_test.py diff --git a/runtime/baseexception.go b/grumpy-runtime-src/runtime/baseexception.go similarity index 100% rename from runtime/baseexception.go rename to grumpy-runtime-src/runtime/baseexception.go diff --git a/runtime/baseexception_test.go b/grumpy-runtime-src/runtime/baseexception_test.go similarity index 100% rename from runtime/baseexception_test.go rename to grumpy-runtime-src/runtime/baseexception_test.go diff --git a/runtime/basestring.go b/grumpy-runtime-src/runtime/basestring.go similarity index 100% rename from runtime/basestring.go rename to grumpy-runtime-src/runtime/basestring.go diff --git a/runtime/basestring_test.go b/grumpy-runtime-src/runtime/basestring_test.go similarity index 100% rename from runtime/basestring_test.go rename to grumpy-runtime-src/runtime/basestring_test.go diff --git a/runtime/bool.go b/grumpy-runtime-src/runtime/bool.go similarity index 100% rename from runtime/bool.go rename to grumpy-runtime-src/runtime/bool.go diff --git a/runtime/bool_test.go b/grumpy-runtime-src/runtime/bool_test.go similarity index 100% rename from runtime/bool_test.go rename to grumpy-runtime-src/runtime/bool_test.go diff --git a/runtime/builtin_types.go b/grumpy-runtime-src/runtime/builtin_types.go similarity index 100% rename from runtime/builtin_types.go rename to grumpy-runtime-src/runtime/builtin_types.go diff --git a/runtime/builtin_types_test.go b/grumpy-runtime-src/runtime/builtin_types_test.go similarity index 100% rename from runtime/builtin_types_test.go rename to grumpy-runtime-src/runtime/builtin_types_test.go diff --git a/runtime/bytearray.go b/grumpy-runtime-src/runtime/bytearray.go similarity index 100% rename from runtime/bytearray.go rename to grumpy-runtime-src/runtime/bytearray.go diff --git a/runtime/bytearray_test.go b/grumpy-runtime-src/runtime/bytearray_test.go similarity index 100% rename from runtime/bytearray_test.go rename to grumpy-runtime-src/runtime/bytearray_test.go diff --git a/runtime/code.go b/grumpy-runtime-src/runtime/code.go similarity index 100% rename from runtime/code.go rename to grumpy-runtime-src/runtime/code.go diff --git a/runtime/code_test.go b/grumpy-runtime-src/runtime/code_test.go similarity index 100% rename from runtime/code_test.go rename to grumpy-runtime-src/runtime/code_test.go diff --git a/runtime/complex.go b/grumpy-runtime-src/runtime/complex.go similarity index 100% rename from runtime/complex.go rename to grumpy-runtime-src/runtime/complex.go diff --git a/runtime/complex_test.go b/grumpy-runtime-src/runtime/complex_test.go similarity index 100% rename from runtime/complex_test.go rename to grumpy-runtime-src/runtime/complex_test.go diff --git a/runtime/core.go b/grumpy-runtime-src/runtime/core.go similarity index 100% rename from runtime/core.go rename to grumpy-runtime-src/runtime/core.go diff --git a/runtime/core_test.go b/grumpy-runtime-src/runtime/core_test.go similarity index 100% rename from runtime/core_test.go rename to grumpy-runtime-src/runtime/core_test.go diff --git a/runtime/descriptor.go b/grumpy-runtime-src/runtime/descriptor.go similarity index 100% rename from runtime/descriptor.go rename to grumpy-runtime-src/runtime/descriptor.go diff --git a/runtime/descriptor_test.go b/grumpy-runtime-src/runtime/descriptor_test.go similarity index 100% rename from runtime/descriptor_test.go rename to grumpy-runtime-src/runtime/descriptor_test.go diff --git a/runtime/dict.go b/grumpy-runtime-src/runtime/dict.go similarity index 100% rename from runtime/dict.go rename to grumpy-runtime-src/runtime/dict.go diff --git a/runtime/dict_test.go b/grumpy-runtime-src/runtime/dict_test.go similarity index 100% rename from runtime/dict_test.go rename to grumpy-runtime-src/runtime/dict_test.go diff --git a/runtime/doc.go b/grumpy-runtime-src/runtime/doc.go similarity index 100% rename from runtime/doc.go rename to grumpy-runtime-src/runtime/doc.go diff --git a/runtime/exceptions.go b/grumpy-runtime-src/runtime/exceptions.go similarity index 100% rename from runtime/exceptions.go rename to grumpy-runtime-src/runtime/exceptions.go diff --git a/runtime/file.go b/grumpy-runtime-src/runtime/file.go similarity index 100% rename from runtime/file.go rename to grumpy-runtime-src/runtime/file.go diff --git a/runtime/file_test.go b/grumpy-runtime-src/runtime/file_test.go similarity index 100% rename from runtime/file_test.go rename to grumpy-runtime-src/runtime/file_test.go diff --git a/runtime/float.go b/grumpy-runtime-src/runtime/float.go similarity index 100% rename from runtime/float.go rename to grumpy-runtime-src/runtime/float.go diff --git a/runtime/float_test.go b/grumpy-runtime-src/runtime/float_test.go similarity index 100% rename from runtime/float_test.go rename to grumpy-runtime-src/runtime/float_test.go diff --git a/runtime/frame.go b/grumpy-runtime-src/runtime/frame.go similarity index 100% rename from runtime/frame.go rename to grumpy-runtime-src/runtime/frame.go diff --git a/runtime/frame_test.go b/grumpy-runtime-src/runtime/frame_test.go similarity index 100% rename from runtime/frame_test.go rename to grumpy-runtime-src/runtime/frame_test.go diff --git a/runtime/function.go b/grumpy-runtime-src/runtime/function.go similarity index 100% rename from runtime/function.go rename to grumpy-runtime-src/runtime/function.go diff --git a/runtime/function_test.go b/grumpy-runtime-src/runtime/function_test.go similarity index 100% rename from runtime/function_test.go rename to grumpy-runtime-src/runtime/function_test.go diff --git a/runtime/generator.go b/grumpy-runtime-src/runtime/generator.go similarity index 100% rename from runtime/generator.go rename to grumpy-runtime-src/runtime/generator.go diff --git a/runtime/generator_test.go b/grumpy-runtime-src/runtime/generator_test.go similarity index 100% rename from runtime/generator_test.go rename to grumpy-runtime-src/runtime/generator_test.go diff --git a/runtime/int.go b/grumpy-runtime-src/runtime/int.go similarity index 100% rename from runtime/int.go rename to grumpy-runtime-src/runtime/int.go diff --git a/runtime/int_test.go b/grumpy-runtime-src/runtime/int_test.go similarity index 100% rename from runtime/int_test.go rename to grumpy-runtime-src/runtime/int_test.go diff --git a/runtime/list.go b/grumpy-runtime-src/runtime/list.go similarity index 100% rename from runtime/list.go rename to grumpy-runtime-src/runtime/list.go diff --git a/runtime/list_test.go b/grumpy-runtime-src/runtime/list_test.go similarity index 100% rename from runtime/list_test.go rename to grumpy-runtime-src/runtime/list_test.go diff --git a/runtime/long.go b/grumpy-runtime-src/runtime/long.go similarity index 100% rename from runtime/long.go rename to grumpy-runtime-src/runtime/long.go diff --git a/runtime/long_test.go b/grumpy-runtime-src/runtime/long_test.go similarity index 100% rename from runtime/long_test.go rename to grumpy-runtime-src/runtime/long_test.go diff --git a/runtime/method.go b/grumpy-runtime-src/runtime/method.go similarity index 100% rename from runtime/method.go rename to grumpy-runtime-src/runtime/method.go diff --git a/runtime/method_test.go b/grumpy-runtime-src/runtime/method_test.go similarity index 100% rename from runtime/method_test.go rename to grumpy-runtime-src/runtime/method_test.go diff --git a/runtime/module.go b/grumpy-runtime-src/runtime/module.go similarity index 100% rename from runtime/module.go rename to grumpy-runtime-src/runtime/module.go diff --git a/runtime/module_test.go b/grumpy-runtime-src/runtime/module_test.go similarity index 100% rename from runtime/module_test.go rename to grumpy-runtime-src/runtime/module_test.go diff --git a/runtime/native.go b/grumpy-runtime-src/runtime/native.go similarity index 100% rename from runtime/native.go rename to grumpy-runtime-src/runtime/native.go diff --git a/runtime/native_test.go b/grumpy-runtime-src/runtime/native_test.go similarity index 100% rename from runtime/native_test.go rename to grumpy-runtime-src/runtime/native_test.go diff --git a/runtime/numeric.go b/grumpy-runtime-src/runtime/numeric.go similarity index 100% rename from runtime/numeric.go rename to grumpy-runtime-src/runtime/numeric.go diff --git a/runtime/object.go b/grumpy-runtime-src/runtime/object.go similarity index 100% rename from runtime/object.go rename to grumpy-runtime-src/runtime/object.go diff --git a/runtime/object_test.go b/grumpy-runtime-src/runtime/object_test.go similarity index 100% rename from runtime/object_test.go rename to grumpy-runtime-src/runtime/object_test.go diff --git a/runtime/param.go b/grumpy-runtime-src/runtime/param.go similarity index 100% rename from runtime/param.go rename to grumpy-runtime-src/runtime/param.go diff --git a/runtime/param_test.go b/grumpy-runtime-src/runtime/param_test.go similarity index 100% rename from runtime/param_test.go rename to grumpy-runtime-src/runtime/param_test.go diff --git a/runtime/range.go b/grumpy-runtime-src/runtime/range.go similarity index 100% rename from runtime/range.go rename to grumpy-runtime-src/runtime/range.go diff --git a/runtime/range_test.go b/grumpy-runtime-src/runtime/range_test.go similarity index 100% rename from runtime/range_test.go rename to grumpy-runtime-src/runtime/range_test.go diff --git a/runtime/seq.go b/grumpy-runtime-src/runtime/seq.go similarity index 100% rename from runtime/seq.go rename to grumpy-runtime-src/runtime/seq.go diff --git a/runtime/seq_test.go b/grumpy-runtime-src/runtime/seq_test.go similarity index 100% rename from runtime/seq_test.go rename to grumpy-runtime-src/runtime/seq_test.go diff --git a/runtime/set.go b/grumpy-runtime-src/runtime/set.go similarity index 100% rename from runtime/set.go rename to grumpy-runtime-src/runtime/set.go diff --git a/runtime/set_test.go b/grumpy-runtime-src/runtime/set_test.go similarity index 100% rename from runtime/set_test.go rename to grumpy-runtime-src/runtime/set_test.go diff --git a/runtime/slice.go b/grumpy-runtime-src/runtime/slice.go similarity index 100% rename from runtime/slice.go rename to grumpy-runtime-src/runtime/slice.go diff --git a/runtime/slice_test.go b/grumpy-runtime-src/runtime/slice_test.go similarity index 100% rename from runtime/slice_test.go rename to grumpy-runtime-src/runtime/slice_test.go diff --git a/runtime/slots.go b/grumpy-runtime-src/runtime/slots.go similarity index 100% rename from runtime/slots.go rename to grumpy-runtime-src/runtime/slots.go diff --git a/runtime/slots_test.go b/grumpy-runtime-src/runtime/slots_test.go similarity index 100% rename from runtime/slots_test.go rename to grumpy-runtime-src/runtime/slots_test.go diff --git a/runtime/str.go b/grumpy-runtime-src/runtime/str.go similarity index 100% rename from runtime/str.go rename to grumpy-runtime-src/runtime/str.go diff --git a/runtime/str_test.go b/grumpy-runtime-src/runtime/str_test.go similarity index 100% rename from runtime/str_test.go rename to grumpy-runtime-src/runtime/str_test.go diff --git a/runtime/super.go b/grumpy-runtime-src/runtime/super.go similarity index 100% rename from runtime/super.go rename to grumpy-runtime-src/runtime/super.go diff --git a/runtime/super_test.go b/grumpy-runtime-src/runtime/super_test.go similarity index 100% rename from runtime/super_test.go rename to grumpy-runtime-src/runtime/super_test.go diff --git a/runtime/threading.go b/grumpy-runtime-src/runtime/threading.go similarity index 100% rename from runtime/threading.go rename to grumpy-runtime-src/runtime/threading.go diff --git a/runtime/threading_test.go b/grumpy-runtime-src/runtime/threading_test.go similarity index 100% rename from runtime/threading_test.go rename to grumpy-runtime-src/runtime/threading_test.go diff --git a/runtime/traceback.go b/grumpy-runtime-src/runtime/traceback.go similarity index 100% rename from runtime/traceback.go rename to grumpy-runtime-src/runtime/traceback.go diff --git a/runtime/tuple.go b/grumpy-runtime-src/runtime/tuple.go similarity index 100% rename from runtime/tuple.go rename to grumpy-runtime-src/runtime/tuple.go diff --git a/runtime/tuple_test.go b/grumpy-runtime-src/runtime/tuple_test.go similarity index 100% rename from runtime/tuple_test.go rename to grumpy-runtime-src/runtime/tuple_test.go diff --git a/runtime/type.go b/grumpy-runtime-src/runtime/type.go similarity index 100% rename from runtime/type.go rename to grumpy-runtime-src/runtime/type.go diff --git a/runtime/type_test.go b/grumpy-runtime-src/runtime/type_test.go similarity index 100% rename from runtime/type_test.go rename to grumpy-runtime-src/runtime/type_test.go diff --git a/runtime/unicode.go b/grumpy-runtime-src/runtime/unicode.go similarity index 100% rename from runtime/unicode.go rename to grumpy-runtime-src/runtime/unicode.go diff --git a/runtime/unicode_test.go b/grumpy-runtime-src/runtime/unicode_test.go similarity index 100% rename from runtime/unicode_test.go rename to grumpy-runtime-src/runtime/unicode_test.go diff --git a/runtime/weakref.go b/grumpy-runtime-src/runtime/weakref.go similarity index 100% rename from runtime/weakref.go rename to grumpy-runtime-src/runtime/weakref.go diff --git a/runtime/weakref_test.go b/grumpy-runtime-src/runtime/weakref_test.go similarity index 100% rename from runtime/weakref_test.go rename to grumpy-runtime-src/runtime/weakref_test.go diff --git a/testing/assert_test.py b/grumpy-runtime-src/testing/assert_test.py similarity index 100% rename from testing/assert_test.py rename to grumpy-runtime-src/testing/assert_test.py diff --git a/testing/assign_test.py b/grumpy-runtime-src/testing/assign_test.py similarity index 100% rename from testing/assign_test.py rename to grumpy-runtime-src/testing/assign_test.py diff --git a/testing/builtin_test.py b/grumpy-runtime-src/testing/builtin_test.py similarity index 100% rename from testing/builtin_test.py rename to grumpy-runtime-src/testing/builtin_test.py diff --git a/testing/class_test.py b/grumpy-runtime-src/testing/class_test.py similarity index 100% rename from testing/class_test.py rename to grumpy-runtime-src/testing/class_test.py diff --git a/testing/compare_test.py b/grumpy-runtime-src/testing/compare_test.py similarity index 100% rename from testing/compare_test.py rename to grumpy-runtime-src/testing/compare_test.py diff --git a/testing/complex_test.py b/grumpy-runtime-src/testing/complex_test.py similarity index 100% rename from testing/complex_test.py rename to grumpy-runtime-src/testing/complex_test.py diff --git a/testing/comprehension_test.py b/grumpy-runtime-src/testing/comprehension_test.py similarity index 100% rename from testing/comprehension_test.py rename to grumpy-runtime-src/testing/comprehension_test.py diff --git a/testing/dict_test.py b/grumpy-runtime-src/testing/dict_test.py similarity index 100% rename from testing/dict_test.py rename to grumpy-runtime-src/testing/dict_test.py diff --git a/testing/file_test.py b/grumpy-runtime-src/testing/file_test.py similarity index 100% rename from testing/file_test.py rename to grumpy-runtime-src/testing/file_test.py diff --git a/testing/float_test.py b/grumpy-runtime-src/testing/float_test.py similarity index 100% rename from testing/float_test.py rename to grumpy-runtime-src/testing/float_test.py diff --git a/testing/for_test.py b/grumpy-runtime-src/testing/for_test.py similarity index 100% rename from testing/for_test.py rename to grumpy-runtime-src/testing/for_test.py diff --git a/testing/function_test.py b/grumpy-runtime-src/testing/function_test.py similarity index 100% rename from testing/function_test.py rename to grumpy-runtime-src/testing/function_test.py diff --git a/testing/generator_test.py b/grumpy-runtime-src/testing/generator_test.py similarity index 100% rename from testing/generator_test.py rename to grumpy-runtime-src/testing/generator_test.py diff --git a/testing/getopt_test.py b/grumpy-runtime-src/testing/getopt_test.py similarity index 100% rename from testing/getopt_test.py rename to grumpy-runtime-src/testing/getopt_test.py diff --git a/testing/global_test.py b/grumpy-runtime-src/testing/global_test.py similarity index 100% rename from testing/global_test.py rename to grumpy-runtime-src/testing/global_test.py diff --git a/testing/if_test.py b/grumpy-runtime-src/testing/if_test.py similarity index 100% rename from testing/if_test.py rename to grumpy-runtime-src/testing/if_test.py diff --git a/testing/import_test.py b/grumpy-runtime-src/testing/import_test.py similarity index 100% rename from testing/import_test.py rename to grumpy-runtime-src/testing/import_test.py diff --git a/testing/list_test.py b/grumpy-runtime-src/testing/list_test.py similarity index 100% rename from testing/list_test.py rename to grumpy-runtime-src/testing/list_test.py diff --git a/testing/native_test.py b/grumpy-runtime-src/testing/native_test.py similarity index 100% rename from testing/native_test.py rename to grumpy-runtime-src/testing/native_test.py diff --git a/testing/op_test.py b/grumpy-runtime-src/testing/op_test.py similarity index 100% rename from testing/op_test.py rename to grumpy-runtime-src/testing/op_test.py diff --git a/testing/pow_test.py b/grumpy-runtime-src/testing/pow_test.py similarity index 100% rename from testing/pow_test.py rename to grumpy-runtime-src/testing/pow_test.py diff --git a/testing/scope_test.py b/grumpy-runtime-src/testing/scope_test.py similarity index 100% rename from testing/scope_test.py rename to grumpy-runtime-src/testing/scope_test.py diff --git a/testing/str_test.py b/grumpy-runtime-src/testing/str_test.py similarity index 100% rename from testing/str_test.py rename to grumpy-runtime-src/testing/str_test.py diff --git a/testing/struct_test.py b/grumpy-runtime-src/testing/struct_test.py similarity index 100% rename from testing/struct_test.py rename to grumpy-runtime-src/testing/struct_test.py diff --git a/testing/try_test.py b/grumpy-runtime-src/testing/try_test.py similarity index 100% rename from testing/try_test.py rename to grumpy-runtime-src/testing/try_test.py diff --git a/testing/tuple_test.py b/grumpy-runtime-src/testing/tuple_test.py similarity index 100% rename from testing/tuple_test.py rename to grumpy-runtime-src/testing/tuple_test.py diff --git a/testing/while_test.py b/grumpy-runtime-src/testing/while_test.py similarity index 100% rename from testing/while_test.py rename to grumpy-runtime-src/testing/while_test.py diff --git a/testing/with_test.py b/grumpy-runtime-src/testing/with_test.py similarity index 100% rename from testing/with_test.py rename to grumpy-runtime-src/testing/with_test.py diff --git a/third_party/ouroboros/AUTHORS b/grumpy-runtime-src/third_party/ouroboros/AUTHORS similarity index 100% rename from third_party/ouroboros/AUTHORS rename to grumpy-runtime-src/third_party/ouroboros/AUTHORS diff --git a/third_party/ouroboros/LICENSE b/grumpy-runtime-src/third_party/ouroboros/LICENSE similarity index 100% rename from third_party/ouroboros/LICENSE rename to grumpy-runtime-src/third_party/ouroboros/LICENSE diff --git a/third_party/ouroboros/READEME.md b/grumpy-runtime-src/third_party/ouroboros/READEME.md similarity index 100% rename from third_party/ouroboros/READEME.md rename to grumpy-runtime-src/third_party/ouroboros/READEME.md diff --git a/third_party/ouroboros/operator.py b/grumpy-runtime-src/third_party/ouroboros/operator.py similarity index 100% rename from third_party/ouroboros/operator.py rename to grumpy-runtime-src/third_party/ouroboros/operator.py diff --git a/third_party/ouroboros/test/test_operator.py b/grumpy-runtime-src/third_party/ouroboros/test/test_operator.py similarity index 100% rename from third_party/ouroboros/test/test_operator.py rename to grumpy-runtime-src/third_party/ouroboros/test/test_operator.py diff --git a/third_party/pypy/LICENSE b/grumpy-runtime-src/third_party/pypy/LICENSE similarity index 100% rename from third_party/pypy/LICENSE rename to grumpy-runtime-src/third_party/pypy/LICENSE diff --git a/third_party/pypy/README.md b/grumpy-runtime-src/third_party/pypy/README.md similarity index 100% rename from third_party/pypy/README.md rename to grumpy-runtime-src/third_party/pypy/README.md diff --git a/third_party/pypy/_collections.py b/grumpy-runtime-src/third_party/pypy/_collections.py similarity index 100% rename from third_party/pypy/_collections.py rename to grumpy-runtime-src/third_party/pypy/_collections.py diff --git a/third_party/pypy/_csv.py b/grumpy-runtime-src/third_party/pypy/_csv.py similarity index 100% rename from third_party/pypy/_csv.py rename to grumpy-runtime-src/third_party/pypy/_csv.py diff --git a/third_party/pypy/_functools.py b/grumpy-runtime-src/third_party/pypy/_functools.py similarity index 100% rename from third_party/pypy/_functools.py rename to grumpy-runtime-src/third_party/pypy/_functools.py diff --git a/third_party/pypy/_md5.py b/grumpy-runtime-src/third_party/pypy/_md5.py similarity index 100% rename from third_party/pypy/_md5.py rename to grumpy-runtime-src/third_party/pypy/_md5.py diff --git a/third_party/pypy/_sha.py b/grumpy-runtime-src/third_party/pypy/_sha.py similarity index 100% rename from third_party/pypy/_sha.py rename to grumpy-runtime-src/third_party/pypy/_sha.py diff --git a/third_party/pypy/_sha256.py b/grumpy-runtime-src/third_party/pypy/_sha256.py similarity index 100% rename from third_party/pypy/_sha256.py rename to grumpy-runtime-src/third_party/pypy/_sha256.py diff --git a/third_party/pypy/_sha512.py b/grumpy-runtime-src/third_party/pypy/_sha512.py similarity index 100% rename from third_party/pypy/_sha512.py rename to grumpy-runtime-src/third_party/pypy/_sha512.py diff --git a/third_party/pypy/_sre.py b/grumpy-runtime-src/third_party/pypy/_sre.py similarity index 100% rename from third_party/pypy/_sre.py rename to grumpy-runtime-src/third_party/pypy/_sre.py diff --git a/third_party/pypy/_struct.py b/grumpy-runtime-src/third_party/pypy/_struct.py similarity index 100% rename from third_party/pypy/_struct.py rename to grumpy-runtime-src/third_party/pypy/_struct.py diff --git a/third_party/pypy/binascii.py b/grumpy-runtime-src/third_party/pypy/binascii.py similarity index 100% rename from third_party/pypy/binascii.py rename to grumpy-runtime-src/third_party/pypy/binascii.py diff --git a/third_party/pypy/datetime.py b/grumpy-runtime-src/third_party/pypy/datetime.py similarity index 100% rename from third_party/pypy/datetime.py rename to grumpy-runtime-src/third_party/pypy/datetime.py diff --git a/third_party/pythonparser/LICENSE.txt b/grumpy-runtime-src/third_party/pythonparser/LICENSE.txt similarity index 100% rename from third_party/pythonparser/LICENSE.txt rename to grumpy-runtime-src/third_party/pythonparser/LICENSE.txt diff --git a/third_party/pythonparser/README.md b/grumpy-runtime-src/third_party/pythonparser/README.md similarity index 100% rename from third_party/pythonparser/README.md rename to grumpy-runtime-src/third_party/pythonparser/README.md diff --git a/third_party/pythonparser/__init__.py b/grumpy-runtime-src/third_party/pythonparser/__init__.py similarity index 100% rename from third_party/pythonparser/__init__.py rename to grumpy-runtime-src/third_party/pythonparser/__init__.py diff --git a/third_party/pythonparser/algorithm.py b/grumpy-runtime-src/third_party/pythonparser/algorithm.py similarity index 100% rename from third_party/pythonparser/algorithm.py rename to grumpy-runtime-src/third_party/pythonparser/algorithm.py diff --git a/third_party/pythonparser/ast.py b/grumpy-runtime-src/third_party/pythonparser/ast.py similarity index 100% rename from third_party/pythonparser/ast.py rename to grumpy-runtime-src/third_party/pythonparser/ast.py diff --git a/third_party/pythonparser/diagnostic.py b/grumpy-runtime-src/third_party/pythonparser/diagnostic.py similarity index 100% rename from third_party/pythonparser/diagnostic.py rename to grumpy-runtime-src/third_party/pythonparser/diagnostic.py diff --git a/third_party/pythonparser/lexer.py b/grumpy-runtime-src/third_party/pythonparser/lexer.py similarity index 100% rename from third_party/pythonparser/lexer.py rename to grumpy-runtime-src/third_party/pythonparser/lexer.py diff --git a/third_party/pythonparser/parser.py b/grumpy-runtime-src/third_party/pythonparser/parser.py similarity index 100% rename from third_party/pythonparser/parser.py rename to grumpy-runtime-src/third_party/pythonparser/parser.py diff --git a/third_party/pythonparser/source.py b/grumpy-runtime-src/third_party/pythonparser/source.py similarity index 100% rename from third_party/pythonparser/source.py rename to grumpy-runtime-src/third_party/pythonparser/source.py diff --git a/third_party/stdlib/LICENSE b/grumpy-runtime-src/third_party/stdlib/LICENSE similarity index 100% rename from third_party/stdlib/LICENSE rename to grumpy-runtime-src/third_party/stdlib/LICENSE diff --git a/third_party/stdlib/Queue.py b/grumpy-runtime-src/third_party/stdlib/Queue.py similarity index 100% rename from third_party/stdlib/Queue.py rename to grumpy-runtime-src/third_party/stdlib/Queue.py diff --git a/third_party/stdlib/README.md b/grumpy-runtime-src/third_party/stdlib/README.md similarity index 100% rename from third_party/stdlib/README.md rename to grumpy-runtime-src/third_party/stdlib/README.md diff --git a/third_party/stdlib/StringIO.py b/grumpy-runtime-src/third_party/stdlib/StringIO.py similarity index 100% rename from third_party/stdlib/StringIO.py rename to grumpy-runtime-src/third_party/stdlib/StringIO.py diff --git a/third_party/stdlib/UserDict.py b/grumpy-runtime-src/third_party/stdlib/UserDict.py similarity index 100% rename from third_party/stdlib/UserDict.py rename to grumpy-runtime-src/third_party/stdlib/UserDict.py diff --git a/third_party/stdlib/UserList.py b/grumpy-runtime-src/third_party/stdlib/UserList.py similarity index 100% rename from third_party/stdlib/UserList.py rename to grumpy-runtime-src/third_party/stdlib/UserList.py diff --git a/third_party/stdlib/UserString.py b/grumpy-runtime-src/third_party/stdlib/UserString.py similarity index 100% rename from third_party/stdlib/UserString.py rename to grumpy-runtime-src/third_party/stdlib/UserString.py diff --git a/third_party/stdlib/_abcoll.py b/grumpy-runtime-src/third_party/stdlib/_abcoll.py similarity index 100% rename from third_party/stdlib/_abcoll.py rename to grumpy-runtime-src/third_party/stdlib/_abcoll.py diff --git a/third_party/stdlib/_weakrefset.py b/grumpy-runtime-src/third_party/stdlib/_weakrefset.py similarity index 100% rename from third_party/stdlib/_weakrefset.py rename to grumpy-runtime-src/third_party/stdlib/_weakrefset.py diff --git a/third_party/stdlib/abc.py b/grumpy-runtime-src/third_party/stdlib/abc.py similarity index 100% rename from third_party/stdlib/abc.py rename to grumpy-runtime-src/third_party/stdlib/abc.py diff --git a/third_party/stdlib/argparse.py b/grumpy-runtime-src/third_party/stdlib/argparse.py similarity index 100% rename from third_party/stdlib/argparse.py rename to grumpy-runtime-src/third_party/stdlib/argparse.py diff --git a/third_party/stdlib/base64.py b/grumpy-runtime-src/third_party/stdlib/base64.py similarity index 100% rename from third_party/stdlib/base64.py rename to grumpy-runtime-src/third_party/stdlib/base64.py diff --git a/third_party/stdlib/bisect.py b/grumpy-runtime-src/third_party/stdlib/bisect.py similarity index 100% rename from third_party/stdlib/bisect.py rename to grumpy-runtime-src/third_party/stdlib/bisect.py diff --git a/third_party/stdlib/collections.py b/grumpy-runtime-src/third_party/stdlib/collections.py similarity index 100% rename from third_party/stdlib/collections.py rename to grumpy-runtime-src/third_party/stdlib/collections.py diff --git a/third_party/stdlib/colorsys.py b/grumpy-runtime-src/third_party/stdlib/colorsys.py similarity index 100% rename from third_party/stdlib/colorsys.py rename to grumpy-runtime-src/third_party/stdlib/colorsys.py diff --git a/third_party/stdlib/contextlib.py b/grumpy-runtime-src/third_party/stdlib/contextlib.py similarity index 100% rename from third_party/stdlib/contextlib.py rename to grumpy-runtime-src/third_party/stdlib/contextlib.py diff --git a/third_party/stdlib/copy.py b/grumpy-runtime-src/third_party/stdlib/copy.py similarity index 100% rename from third_party/stdlib/copy.py rename to grumpy-runtime-src/third_party/stdlib/copy.py diff --git a/third_party/stdlib/copy_reg.py b/grumpy-runtime-src/third_party/stdlib/copy_reg.py similarity index 100% rename from third_party/stdlib/copy_reg.py rename to grumpy-runtime-src/third_party/stdlib/copy_reg.py diff --git a/third_party/stdlib/csv.py b/grumpy-runtime-src/third_party/stdlib/csv.py similarity index 100% rename from third_party/stdlib/csv.py rename to grumpy-runtime-src/third_party/stdlib/csv.py diff --git a/third_party/stdlib/difflib.py b/grumpy-runtime-src/third_party/stdlib/difflib.py similarity index 100% rename from third_party/stdlib/difflib.py rename to grumpy-runtime-src/third_party/stdlib/difflib.py diff --git a/third_party/stdlib/dircache.py b/grumpy-runtime-src/third_party/stdlib/dircache.py similarity index 100% rename from third_party/stdlib/dircache.py rename to grumpy-runtime-src/third_party/stdlib/dircache.py diff --git a/third_party/stdlib/dummy_thread.py b/grumpy-runtime-src/third_party/stdlib/dummy_thread.py similarity index 100% rename from third_party/stdlib/dummy_thread.py rename to grumpy-runtime-src/third_party/stdlib/dummy_thread.py diff --git a/third_party/stdlib/fnmatch.py b/grumpy-runtime-src/third_party/stdlib/fnmatch.py similarity index 100% rename from third_party/stdlib/fnmatch.py rename to grumpy-runtime-src/third_party/stdlib/fnmatch.py diff --git a/third_party/stdlib/fpformat.py b/grumpy-runtime-src/third_party/stdlib/fpformat.py similarity index 100% rename from third_party/stdlib/fpformat.py rename to grumpy-runtime-src/third_party/stdlib/fpformat.py diff --git a/third_party/stdlib/functools.py b/grumpy-runtime-src/third_party/stdlib/functools.py similarity index 100% rename from third_party/stdlib/functools.py rename to grumpy-runtime-src/third_party/stdlib/functools.py diff --git a/third_party/stdlib/genericpath.py b/grumpy-runtime-src/third_party/stdlib/genericpath.py similarity index 100% rename from third_party/stdlib/genericpath.py rename to grumpy-runtime-src/third_party/stdlib/genericpath.py diff --git a/third_party/stdlib/getopt.py b/grumpy-runtime-src/third_party/stdlib/getopt.py similarity index 100% rename from third_party/stdlib/getopt.py rename to grumpy-runtime-src/third_party/stdlib/getopt.py diff --git a/third_party/stdlib/glob.py b/grumpy-runtime-src/third_party/stdlib/glob.py similarity index 100% rename from third_party/stdlib/glob.py rename to grumpy-runtime-src/third_party/stdlib/glob.py diff --git a/third_party/stdlib/heapq.py b/grumpy-runtime-src/third_party/stdlib/heapq.py similarity index 100% rename from third_party/stdlib/heapq.py rename to grumpy-runtime-src/third_party/stdlib/heapq.py diff --git a/third_party/stdlib/json/__init__.py b/grumpy-runtime-src/third_party/stdlib/json/__init__.py similarity index 100% rename from third_party/stdlib/json/__init__.py rename to grumpy-runtime-src/third_party/stdlib/json/__init__.py diff --git a/third_party/stdlib/json/decoder.py b/grumpy-runtime-src/third_party/stdlib/json/decoder.py similarity index 100% rename from third_party/stdlib/json/decoder.py rename to grumpy-runtime-src/third_party/stdlib/json/decoder.py diff --git a/third_party/stdlib/json/encoder.py b/grumpy-runtime-src/third_party/stdlib/json/encoder.py similarity index 100% rename from third_party/stdlib/json/encoder.py rename to grumpy-runtime-src/third_party/stdlib/json/encoder.py diff --git a/third_party/stdlib/json_scanner.py b/grumpy-runtime-src/third_party/stdlib/json_scanner.py similarity index 100% rename from third_party/stdlib/json_scanner.py rename to grumpy-runtime-src/third_party/stdlib/json_scanner.py diff --git a/third_party/stdlib/keyword.py b/grumpy-runtime-src/third_party/stdlib/keyword.py similarity index 100% rename from third_party/stdlib/keyword.py rename to grumpy-runtime-src/third_party/stdlib/keyword.py diff --git a/third_party/stdlib/linecache.py b/grumpy-runtime-src/third_party/stdlib/linecache.py similarity index 100% rename from third_party/stdlib/linecache.py rename to grumpy-runtime-src/third_party/stdlib/linecache.py diff --git a/third_party/stdlib/md5.py b/grumpy-runtime-src/third_party/stdlib/md5.py similarity index 100% rename from third_party/stdlib/md5.py rename to grumpy-runtime-src/third_party/stdlib/md5.py diff --git a/third_party/stdlib/mimetools.py b/grumpy-runtime-src/third_party/stdlib/mimetools.py similarity index 100% rename from third_party/stdlib/mimetools.py rename to grumpy-runtime-src/third_party/stdlib/mimetools.py diff --git a/third_party/stdlib/mutex.py b/grumpy-runtime-src/third_party/stdlib/mutex.py similarity index 100% rename from third_party/stdlib/mutex.py rename to grumpy-runtime-src/third_party/stdlib/mutex.py diff --git a/third_party/stdlib/optparse.py b/grumpy-runtime-src/third_party/stdlib/optparse.py similarity index 100% rename from third_party/stdlib/optparse.py rename to grumpy-runtime-src/third_party/stdlib/optparse.py diff --git a/third_party/stdlib/pprint.py b/grumpy-runtime-src/third_party/stdlib/pprint.py similarity index 100% rename from third_party/stdlib/pprint.py rename to grumpy-runtime-src/third_party/stdlib/pprint.py diff --git a/third_party/stdlib/quopri.py b/grumpy-runtime-src/third_party/stdlib/quopri.py similarity index 100% rename from third_party/stdlib/quopri.py rename to grumpy-runtime-src/third_party/stdlib/quopri.py diff --git a/third_party/stdlib/random.py b/grumpy-runtime-src/third_party/stdlib/random.py similarity index 100% rename from third_party/stdlib/random.py rename to grumpy-runtime-src/third_party/stdlib/random.py diff --git a/third_party/stdlib/re.py b/grumpy-runtime-src/third_party/stdlib/re.py similarity index 100% rename from third_party/stdlib/re.py rename to grumpy-runtime-src/third_party/stdlib/re.py diff --git a/third_party/stdlib/re_tests.py b/grumpy-runtime-src/third_party/stdlib/re_tests.py similarity index 100% rename from third_party/stdlib/re_tests.py rename to grumpy-runtime-src/third_party/stdlib/re_tests.py diff --git a/third_party/stdlib/repr.py b/grumpy-runtime-src/third_party/stdlib/repr.py similarity index 100% rename from third_party/stdlib/repr.py rename to grumpy-runtime-src/third_party/stdlib/repr.py diff --git a/third_party/stdlib/rfc822.py b/grumpy-runtime-src/third_party/stdlib/rfc822.py similarity index 100% rename from third_party/stdlib/rfc822.py rename to grumpy-runtime-src/third_party/stdlib/rfc822.py diff --git a/third_party/stdlib/sched.py b/grumpy-runtime-src/third_party/stdlib/sched.py similarity index 100% rename from third_party/stdlib/sched.py rename to grumpy-runtime-src/third_party/stdlib/sched.py diff --git a/third_party/stdlib/sha.py b/grumpy-runtime-src/third_party/stdlib/sha.py similarity index 100% rename from third_party/stdlib/sha.py rename to grumpy-runtime-src/third_party/stdlib/sha.py diff --git a/third_party/stdlib/sre_compile.py b/grumpy-runtime-src/third_party/stdlib/sre_compile.py similarity index 100% rename from third_party/stdlib/sre_compile.py rename to grumpy-runtime-src/third_party/stdlib/sre_compile.py diff --git a/third_party/stdlib/sre_constants.py b/grumpy-runtime-src/third_party/stdlib/sre_constants.py similarity index 100% rename from third_party/stdlib/sre_constants.py rename to grumpy-runtime-src/third_party/stdlib/sre_constants.py diff --git a/third_party/stdlib/sre_parse.py b/grumpy-runtime-src/third_party/stdlib/sre_parse.py similarity index 100% rename from third_party/stdlib/sre_parse.py rename to grumpy-runtime-src/third_party/stdlib/sre_parse.py diff --git a/third_party/stdlib/string.py b/grumpy-runtime-src/third_party/stdlib/string.py similarity index 100% rename from third_party/stdlib/string.py rename to grumpy-runtime-src/third_party/stdlib/string.py diff --git a/third_party/stdlib/test/__init__.py b/grumpy-runtime-src/third_party/stdlib/test/__init__.py similarity index 100% rename from third_party/stdlib/test/__init__.py rename to grumpy-runtime-src/third_party/stdlib/test/__init__.py diff --git a/third_party/stdlib/test/list_tests.py b/grumpy-runtime-src/third_party/stdlib/test/list_tests.py similarity index 100% rename from third_party/stdlib/test/list_tests.py rename to grumpy-runtime-src/third_party/stdlib/test/list_tests.py diff --git a/third_party/stdlib/test/lock_tests.py b/grumpy-runtime-src/third_party/stdlib/test/lock_tests.py similarity index 100% rename from third_party/stdlib/test/lock_tests.py rename to grumpy-runtime-src/third_party/stdlib/test/lock_tests.py diff --git a/third_party/stdlib/test/mapping_tests.py b/grumpy-runtime-src/third_party/stdlib/test/mapping_tests.py similarity index 100% rename from third_party/stdlib/test/mapping_tests.py rename to grumpy-runtime-src/third_party/stdlib/test/mapping_tests.py diff --git a/third_party/stdlib/test/seq_tests.py b/grumpy-runtime-src/third_party/stdlib/test/seq_tests.py similarity index 100% rename from third_party/stdlib/test/seq_tests.py rename to grumpy-runtime-src/third_party/stdlib/test/seq_tests.py diff --git a/third_party/stdlib/test/string_tests.py b/grumpy-runtime-src/third_party/stdlib/test/string_tests.py similarity index 100% rename from third_party/stdlib/test/string_tests.py rename to grumpy-runtime-src/third_party/stdlib/test/string_tests.py diff --git a/third_party/stdlib/test/test_argparse.py b/grumpy-runtime-src/third_party/stdlib/test/test_argparse.py similarity index 100% rename from third_party/stdlib/test/test_argparse.py rename to grumpy-runtime-src/third_party/stdlib/test/test_argparse.py diff --git a/third_party/stdlib/test/test_bisect.py b/grumpy-runtime-src/third_party/stdlib/test/test_bisect.py similarity index 100% rename from third_party/stdlib/test/test_bisect.py rename to grumpy-runtime-src/third_party/stdlib/test/test_bisect.py diff --git a/third_party/stdlib/test/test_colorsys.py b/grumpy-runtime-src/third_party/stdlib/test/test_colorsys.py similarity index 100% rename from third_party/stdlib/test/test_colorsys.py rename to grumpy-runtime-src/third_party/stdlib/test/test_colorsys.py diff --git a/third_party/stdlib/test/test_datetime.py b/grumpy-runtime-src/third_party/stdlib/test/test_datetime.py similarity index 100% rename from third_party/stdlib/test/test_datetime.py rename to grumpy-runtime-src/third_party/stdlib/test/test_datetime.py diff --git a/third_party/stdlib/test/test_dict.py b/grumpy-runtime-src/third_party/stdlib/test/test_dict.py similarity index 100% rename from third_party/stdlib/test/test_dict.py rename to grumpy-runtime-src/third_party/stdlib/test/test_dict.py diff --git a/third_party/stdlib/test/test_dircache.py b/grumpy-runtime-src/third_party/stdlib/test/test_dircache.py similarity index 100% rename from third_party/stdlib/test/test_dircache.py rename to grumpy-runtime-src/third_party/stdlib/test/test_dircache.py diff --git a/third_party/stdlib/test/test_dummy_thread.py b/grumpy-runtime-src/third_party/stdlib/test/test_dummy_thread.py similarity index 100% rename from third_party/stdlib/test/test_dummy_thread.py rename to grumpy-runtime-src/third_party/stdlib/test/test_dummy_thread.py diff --git a/third_party/stdlib/test/test_fpformat.py b/grumpy-runtime-src/third_party/stdlib/test/test_fpformat.py similarity index 100% rename from third_party/stdlib/test/test_fpformat.py rename to grumpy-runtime-src/third_party/stdlib/test/test_fpformat.py diff --git a/third_party/stdlib/test/test_genericpath.py b/grumpy-runtime-src/third_party/stdlib/test/test_genericpath.py similarity index 100% rename from third_party/stdlib/test/test_genericpath.py rename to grumpy-runtime-src/third_party/stdlib/test/test_genericpath.py diff --git a/third_party/stdlib/test/test_list.py b/grumpy-runtime-src/third_party/stdlib/test/test_list.py similarity index 100% rename from third_party/stdlib/test/test_list.py rename to grumpy-runtime-src/third_party/stdlib/test/test_list.py diff --git a/third_party/stdlib/test/test_md5.py b/grumpy-runtime-src/third_party/stdlib/test/test_md5.py similarity index 100% rename from third_party/stdlib/test/test_md5.py rename to grumpy-runtime-src/third_party/stdlib/test/test_md5.py diff --git a/third_party/stdlib/test/test_mimetools.py b/grumpy-runtime-src/third_party/stdlib/test/test_mimetools.py similarity index 100% rename from third_party/stdlib/test/test_mimetools.py rename to grumpy-runtime-src/third_party/stdlib/test/test_mimetools.py diff --git a/third_party/stdlib/test/test_mutex.py b/grumpy-runtime-src/third_party/stdlib/test/test_mutex.py similarity index 100% rename from third_party/stdlib/test/test_mutex.py rename to grumpy-runtime-src/third_party/stdlib/test/test_mutex.py diff --git a/third_party/stdlib/test/test_queue.py b/grumpy-runtime-src/third_party/stdlib/test/test_queue.py similarity index 100% rename from third_party/stdlib/test/test_queue.py rename to grumpy-runtime-src/third_party/stdlib/test/test_queue.py diff --git a/third_party/stdlib/test/test_quopri.py b/grumpy-runtime-src/third_party/stdlib/test/test_quopri.py similarity index 100% rename from third_party/stdlib/test/test_quopri.py rename to grumpy-runtime-src/third_party/stdlib/test/test_quopri.py diff --git a/third_party/stdlib/test/test_rfc822.py b/grumpy-runtime-src/third_party/stdlib/test/test_rfc822.py similarity index 100% rename from third_party/stdlib/test/test_rfc822.py rename to grumpy-runtime-src/third_party/stdlib/test/test_rfc822.py diff --git a/third_party/stdlib/test/test_sched.py b/grumpy-runtime-src/third_party/stdlib/test/test_sched.py similarity index 100% rename from third_party/stdlib/test/test_sched.py rename to grumpy-runtime-src/third_party/stdlib/test/test_sched.py diff --git a/third_party/stdlib/test/test_select.py b/grumpy-runtime-src/third_party/stdlib/test/test_select.py similarity index 100% rename from third_party/stdlib/test/test_select.py rename to grumpy-runtime-src/third_party/stdlib/test/test_select.py diff --git a/third_party/stdlib/test/test_slice.py b/grumpy-runtime-src/third_party/stdlib/test/test_slice.py similarity index 100% rename from third_party/stdlib/test/test_slice.py rename to grumpy-runtime-src/third_party/stdlib/test/test_slice.py diff --git a/third_party/stdlib/test/test_stat.py b/grumpy-runtime-src/third_party/stdlib/test/test_stat.py similarity index 100% rename from third_party/stdlib/test/test_stat.py rename to grumpy-runtime-src/third_party/stdlib/test/test_stat.py diff --git a/third_party/stdlib/test/test_string.py b/grumpy-runtime-src/third_party/stdlib/test/test_string.py similarity index 100% rename from third_party/stdlib/test/test_string.py rename to grumpy-runtime-src/third_party/stdlib/test/test_string.py diff --git a/third_party/stdlib/test/test_support.py b/grumpy-runtime-src/third_party/stdlib/test/test_support.py similarity index 100% rename from third_party/stdlib/test/test_support.py rename to grumpy-runtime-src/third_party/stdlib/test/test_support.py diff --git a/third_party/stdlib/test/test_threading.py b/grumpy-runtime-src/third_party/stdlib/test/test_threading.py similarity index 100% rename from third_party/stdlib/test/test_threading.py rename to grumpy-runtime-src/third_party/stdlib/test/test_threading.py diff --git a/third_party/stdlib/test/test_tuple.py b/grumpy-runtime-src/third_party/stdlib/test/test_tuple.py similarity index 100% rename from third_party/stdlib/test/test_tuple.py rename to grumpy-runtime-src/third_party/stdlib/test/test_tuple.py diff --git a/third_party/stdlib/test/test_uu.py b/grumpy-runtime-src/third_party/stdlib/test/test_uu.py similarity index 100% rename from third_party/stdlib/test/test_uu.py rename to grumpy-runtime-src/third_party/stdlib/test/test_uu.py diff --git a/third_party/stdlib/textwrap.py b/grumpy-runtime-src/third_party/stdlib/textwrap.py similarity index 100% rename from third_party/stdlib/textwrap.py rename to grumpy-runtime-src/third_party/stdlib/textwrap.py diff --git a/third_party/stdlib/threading.py b/grumpy-runtime-src/third_party/stdlib/threading.py similarity index 100% rename from third_party/stdlib/threading.py rename to grumpy-runtime-src/third_party/stdlib/threading.py diff --git a/third_party/stdlib/traceback.py b/grumpy-runtime-src/third_party/stdlib/traceback.py similarity index 100% rename from third_party/stdlib/traceback.py rename to grumpy-runtime-src/third_party/stdlib/traceback.py diff --git a/third_party/stdlib/types.py b/grumpy-runtime-src/third_party/stdlib/types.py similarity index 100% rename from third_party/stdlib/types.py rename to grumpy-runtime-src/third_party/stdlib/types.py diff --git a/third_party/stdlib/unittest/__init__.py b/grumpy-runtime-src/third_party/stdlib/unittest/__init__.py similarity index 100% rename from third_party/stdlib/unittest/__init__.py rename to grumpy-runtime-src/third_party/stdlib/unittest/__init__.py diff --git a/third_party/stdlib/unittest_case.py b/grumpy-runtime-src/third_party/stdlib/unittest_case.py similarity index 100% rename from third_party/stdlib/unittest_case.py rename to grumpy-runtime-src/third_party/stdlib/unittest_case.py diff --git a/third_party/stdlib/unittest_loader.py b/grumpy-runtime-src/third_party/stdlib/unittest_loader.py similarity index 100% rename from third_party/stdlib/unittest_loader.py rename to grumpy-runtime-src/third_party/stdlib/unittest_loader.py diff --git a/third_party/stdlib/unittest_result.py b/grumpy-runtime-src/third_party/stdlib/unittest_result.py similarity index 100% rename from third_party/stdlib/unittest_result.py rename to grumpy-runtime-src/third_party/stdlib/unittest_result.py diff --git a/third_party/stdlib/unittest_runner.py b/grumpy-runtime-src/third_party/stdlib/unittest_runner.py similarity index 100% rename from third_party/stdlib/unittest_runner.py rename to grumpy-runtime-src/third_party/stdlib/unittest_runner.py diff --git a/third_party/stdlib/unittest_signals.py b/grumpy-runtime-src/third_party/stdlib/unittest_signals.py similarity index 100% rename from third_party/stdlib/unittest_signals.py rename to grumpy-runtime-src/third_party/stdlib/unittest_signals.py diff --git a/third_party/stdlib/unittest_suite.py b/grumpy-runtime-src/third_party/stdlib/unittest_suite.py similarity index 100% rename from third_party/stdlib/unittest_suite.py rename to grumpy-runtime-src/third_party/stdlib/unittest_suite.py diff --git a/third_party/stdlib/unittest_util.py b/grumpy-runtime-src/third_party/stdlib/unittest_util.py similarity index 100% rename from third_party/stdlib/unittest_util.py rename to grumpy-runtime-src/third_party/stdlib/unittest_util.py diff --git a/third_party/stdlib/urlparse.py b/grumpy-runtime-src/third_party/stdlib/urlparse.py similarity index 100% rename from third_party/stdlib/urlparse.py rename to grumpy-runtime-src/third_party/stdlib/urlparse.py diff --git a/third_party/stdlib/uu.py b/grumpy-runtime-src/third_party/stdlib/uu.py similarity index 100% rename from third_party/stdlib/uu.py rename to grumpy-runtime-src/third_party/stdlib/uu.py diff --git a/third_party/stdlib/warnings.py b/grumpy-runtime-src/third_party/stdlib/warnings.py similarity index 100% rename from third_party/stdlib/warnings.py rename to grumpy-runtime-src/third_party/stdlib/warnings.py diff --git a/third_party/stdlib/weakref.py b/grumpy-runtime-src/third_party/stdlib/weakref.py similarity index 100% rename from third_party/stdlib/weakref.py rename to grumpy-runtime-src/third_party/stdlib/weakref.py diff --git a/tools/benchcmp b/grumpy-runtime-src/tools/benchcmp similarity index 100% rename from tools/benchcmp rename to grumpy-runtime-src/tools/benchcmp diff --git a/tools/coverparse b/grumpy-runtime-src/tools/coverparse similarity index 100% rename from tools/coverparse rename to grumpy-runtime-src/tools/coverparse diff --git a/tools/diffrange b/grumpy-runtime-src/tools/diffrange similarity index 100% rename from tools/diffrange rename to grumpy-runtime-src/tools/diffrange diff --git a/tools/genmake b/grumpy-runtime-src/tools/genmake similarity index 100% rename from tools/genmake rename to grumpy-runtime-src/tools/genmake diff --git a/tools/grumpc b/grumpy-runtime-src/tools/grumpc similarity index 100% rename from tools/grumpc rename to grumpy-runtime-src/tools/grumpc diff --git a/tools/grumprun b/grumpy-runtime-src/tools/grumprun similarity index 100% rename from tools/grumprun rename to grumpy-runtime-src/tools/grumprun diff --git a/tools/pkgc.go b/grumpy-runtime-src/tools/pkgc.go similarity index 100% rename from tools/pkgc.go rename to grumpy-runtime-src/tools/pkgc.go diff --git a/tools/pydeps b/grumpy-runtime-src/tools/pydeps similarity index 100% rename from tools/pydeps rename to grumpy-runtime-src/tools/pydeps diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..301133af --- /dev/null +++ b/setup.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""The setup script.""" + +from setuptools import setup, find_packages + +with open('README.md') as readme_file: + readme = readme_file.read() + +requirements = [ + 'Click>=6.0', + # TODO: Put package requirements here + 'importlib2>=3.5.0.2', + 'click-default-group>=1.2', +] + +setup_requirements = [ + 'pytest-runner', + # TODO(alanjds): Put setup requirements (distutils extensions, etc.) here +] + +test_requirements = [ + 'pytest', + # TODO: Put package test requirements here +] + +setup( + name='grumpy-tools', + version='0.1.0', + description="Grumpy Runtime & Transpiler", + long_description=readme, + author="Dylan Trotter et al.", + maintainer="Alan Justino", + maintainer_email="alan.justino@yahoo.com.br", + url='https://github.com/alanjds/grumpy', + package_dir={'':'grumpy-tools-src'}, + packages=find_packages( + 'grumpy-tools-src', + exclude=["*.tests", "*.tests.*", "tests.*", "tests"], + ), + entry_points={ + 'console_scripts': [ + 'grumpy=grumpy.cli:main', + ], + }, + include_package_data=True, + install_requires=requirements, + license="Apache Software License 2.0", + zip_safe=False, + keywords='grumpy_runtime', + python_requires='~=2.7.0', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + "Programming Language :: Python :: 2", + 'Programming Language :: Python :: 2.7', + ], + test_suite='tests', + tests_require=test_requirements, + setup_requires=setup_requirements, +) From 04106eb2a9a16d3dac63397a560fa2e6e46acccc Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 17:46:14 -0300 Subject: [PATCH 04/73] Fixed imports and CLI namespaces --- grumpy-tools-src/grumpy_tools/__init__.py | 7 ++ grumpy-tools-src/grumpy_tools/benchcmp.py | 90 +++++++++++++++ grumpy-tools-src/grumpy_tools/cli.py | 37 +++++++ .../grumpy_tools}/compiler/__init__.py | 0 .../grumpy_tools}/compiler/block.py | 10 +- .../grumpy_tools}/compiler/block_test.py | 2 +- .../grumpy_tools}/compiler/expr.py | 2 +- .../grumpy_tools}/compiler/expr_visitor.py | 8 +- .../compiler/expr_visitor_test.py | 2 +- .../grumpy_tools}/compiler/imputil.py | 8 +- .../grumpy_tools}/compiler/imputil_test.py | 2 +- .../grumpy_tools}/compiler/shard_test.py | 0 .../grumpy_tools}/compiler/stmt.py | 14 +-- .../grumpy_tools}/compiler/stmt_test.py | 4 +- .../grumpy_tools}/compiler/util.py | 7 +- .../grumpy_tools}/compiler/util_test.py | 0 grumpy-tools-src/grumpy_tools/coverparse.py | 51 +++++++++ grumpy-tools-src/grumpy_tools/diffrange.py | 83 ++++++++++++++ grumpy-tools-src/grumpy_tools/genmake.py | 87 +++++++++++++++ grumpy-tools-src/grumpy_tools/grumpc.py | 95 ++++++++++++++++ grumpy-tools-src/grumpy_tools/grumprun.py | 104 ++++++++++++++++++ grumpy-tools-src/grumpy_tools/grumpy_tools.py | 3 + grumpy-tools-src/grumpy_tools/pydeps.py | 63 +++++++++++ .../grumpy_tools/vendor/__init__.py | 0 .../vendor}/pythonparser/LICENSE.txt | 0 .../vendor}/pythonparser/README.md | 0 .../vendor}/pythonparser/__init__.py | 0 .../vendor}/pythonparser/algorithm.py | 0 .../grumpy_tools/vendor}/pythonparser/ast.py | 0 .../vendor}/pythonparser/diagnostic.py | 0 .../vendor}/pythonparser/lexer.py | 0 .../vendor}/pythonparser/parser.py | 0 .../vendor}/pythonparser/source.py | 0 grumpy-tools-src/tests/test_grumpy_tools.py | 37 +++++++ setup.py | 2 +- 35 files changed, 689 insertions(+), 29 deletions(-) create mode 100644 grumpy-tools-src/grumpy_tools/__init__.py create mode 100755 grumpy-tools-src/grumpy_tools/benchcmp.py create mode 100644 grumpy-tools-src/grumpy_tools/cli.py rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/__init__.py (100%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/block.py (98%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/block_test.py (99%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/expr.py (98%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/expr_visitor.py (98%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/expr_visitor_test.py (99%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/imputil.py (98%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/imputil_test.py (99%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/shard_test.py (100%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/stmt.py (99%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/stmt_test.py (99%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/util.py (96%) rename {grumpy-runtime-src => grumpy-tools-src/grumpy_tools}/compiler/util_test.py (100%) create mode 100755 grumpy-tools-src/grumpy_tools/coverparse.py create mode 100755 grumpy-tools-src/grumpy_tools/diffrange.py create mode 100755 grumpy-tools-src/grumpy_tools/genmake.py create mode 100755 grumpy-tools-src/grumpy_tools/grumpc.py create mode 100755 grumpy-tools-src/grumpy_tools/grumprun.py create mode 100644 grumpy-tools-src/grumpy_tools/grumpy_tools.py create mode 100755 grumpy-tools-src/grumpy_tools/pydeps.py create mode 100644 grumpy-tools-src/grumpy_tools/vendor/__init__.py rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/LICENSE.txt (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/README.md (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/__init__.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/algorithm.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/ast.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/diagnostic.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/lexer.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/parser.py (100%) rename {grumpy-runtime-src/third_party => grumpy-tools-src/grumpy_tools/vendor}/pythonparser/source.py (100%) create mode 100644 grumpy-tools-src/tests/test_grumpy_tools.py diff --git a/grumpy-tools-src/grumpy_tools/__init__.py b/grumpy-tools-src/grumpy_tools/__init__.py new file mode 100644 index 00000000..ed7f12d5 --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +"""Top-level package for Grumpy Tools.""" + +__author__ = """Alan Justino et al.""" +__email__ = 'alan.justino@yahoo.com.br' +__version__ = '0.1.0' diff --git a/grumpy-tools-src/grumpy_tools/benchcmp.py b/grumpy-tools-src/grumpy_tools/benchcmp.py new file mode 100755 index 00000000..be4dafc2 --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/benchcmp.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Runs two benchmark programs and compares their results.""" + +import argparse +import subprocess +import sys + + +parser = argparse.ArgumentParser() +parser.add_argument('prog1') +parser.add_argument('prog2') +parser.add_argument('--runs', default=1, type=int, + help='number of times to run each program') + + +def main(args): + results1 = _RunBenchmark(args.prog1) + benchmarks = set(results1.keys()) + results2 = {} + for _ in xrange(args.runs - 1): + _MergeResults(results1, _RunBenchmark(args.prog1), benchmarks) + _MergeResults(results2, _RunBenchmark(args.prog2), benchmarks) + _MergeResults(results2, _RunBenchmark(args.prog2), benchmarks) + for b in sorted(benchmarks): + print b, '{:+.1%}'.format(results2[b] / results1[b] - 1) + + +def _MergeResults(merged, results, benchmarks): + benchmarks = set(benchmarks) + for k, v in results.iteritems(): + if k not in benchmarks: + _Die('unmatched benchmark: {}', k) + merged[k] = max(merged.get(k, 0), v) + benchmarks.remove(k) + if benchmarks: + _Die('missing benchmark(s): {}', ', '.join(benchmarks)) + + +def _RunBenchmark(prog): + """Executes prog and returns a dict mapping benchmark name -> result.""" + try: + p = subprocess.Popen([prog], shell=True, stdout=subprocess.PIPE) + except OSError as e: + _Die(e) + out, _ = p.communicate() + if p.returncode: + _Die('{} exited with status: {}', prog, p.returncode) + results = {} + for line in out.splitlines(): + line = line.strip() + if not line: + continue + parts = line.split() + if len(parts) != 3: + _Die('invalid benchmark output: {}', line) + name, status, result = parts + if status != 'PASSED': + _Die('benchmark failed: {}', line) + try: + result = float(result) + except ValueError: + _Die('invalid benchmark result: {}', line) + results[name] = result + return results + + +def _Die(msg, *args): + if args: + msg = msg.format(*args) + print >> sys.stderr, msg + sys.exit(1) + + +if __name__ == '__main__': + main(parser.parse_args()) diff --git a/grumpy-tools-src/grumpy_tools/cli.py b/grumpy-tools-src/grumpy_tools/cli.py new file mode 100644 index 00000000..94b4e46c --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/cli.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +"""Console script for grumpy_tools.""" +import sys + +import click + +from . import grumpc, grumprun + + +@click.group('grumpy') +def main(args=None): + """Console script for grumpy_tools.""" + return 0 + + +@main.command('transpile') +@click.argument('script') +@click.option('-m', '-modname', '--modname', default='__main__', help='Python module name') +def transpile(script=None, modname=None): + """ + Translates the python SCRIPT file to Go, then prints to stdout + """ + result = grumpc.main(script=script, modname=modname) + sys.exit(result) + + +@main.command('run') +@click.option('-m', '-modname', '--modname', help='Run the named module') +def run(modname=None): + result = grumprun.main(modname=modname) + sys.exit(result) + + +if __name__ == "__main__": + import sys + sys.exit(main()) diff --git a/grumpy-runtime-src/compiler/__init__.py b/grumpy-tools-src/grumpy_tools/compiler/__init__.py similarity index 100% rename from grumpy-runtime-src/compiler/__init__.py rename to grumpy-tools-src/grumpy_tools/compiler/__init__.py diff --git a/grumpy-runtime-src/compiler/block.py b/grumpy-tools-src/grumpy_tools/compiler/block.py similarity index 98% rename from grumpy-runtime-src/compiler/block.py rename to grumpy-tools-src/grumpy_tools/compiler/block.py index 423ded2d..2287fab2 100644 --- a/grumpy-runtime-src/compiler/block.py +++ b/grumpy-tools-src/grumpy_tools/compiler/block.py @@ -22,11 +22,11 @@ import collections import re -from grumpy.compiler import expr -from grumpy.compiler import util -from grumpy.pythonparser import algorithm -from grumpy.pythonparser import ast -from grumpy.pythonparser import source +from grumpy_tools.compiler import expr +from grumpy_tools.compiler import util +from grumpy_tools.vendor.pythonparser import algorithm +from grumpy_tools.vendor.pythonparser import ast +from grumpy_tools.vendor.pythonparser import source _non_word_re = re.compile('[^A-Za-z0-9_]') diff --git a/grumpy-runtime-src/compiler/block_test.py b/grumpy-tools-src/grumpy_tools/compiler/block_test.py similarity index 99% rename from grumpy-runtime-src/compiler/block_test.py rename to grumpy-tools-src/grumpy_tools/compiler/block_test.py index 63376997..7b045fa5 100644 --- a/grumpy-runtime-src/compiler/block_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/block_test.py @@ -24,7 +24,7 @@ from grumpy.compiler import block from grumpy.compiler import imputil from grumpy.compiler import util -from grumpy import pythonparser +from grumpy.vendor import pythonparser class PackageTest(unittest.TestCase): diff --git a/grumpy-runtime-src/compiler/expr.py b/grumpy-tools-src/grumpy_tools/compiler/expr.py similarity index 98% rename from grumpy-runtime-src/compiler/expr.py rename to grumpy-tools-src/grumpy_tools/compiler/expr.py index bdc72966..1cc08d10 100644 --- a/grumpy-runtime-src/compiler/expr.py +++ b/grumpy-tools-src/grumpy_tools/compiler/expr.py @@ -20,7 +20,7 @@ import abc -from grumpy.compiler import util +from grumpy_tools.compiler import util class GeneratedExpr(object): diff --git a/grumpy-runtime-src/compiler/expr_visitor.py b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor.py similarity index 98% rename from grumpy-runtime-src/compiler/expr_visitor.py rename to grumpy-tools-src/grumpy_tools/compiler/expr_visitor.py index 267abdf7..1432f6a3 100644 --- a/grumpy-runtime-src/compiler/expr_visitor.py +++ b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor.py @@ -21,10 +21,10 @@ import contextlib import textwrap -from grumpy.compiler import expr -from grumpy.compiler import util -from grumpy.pythonparser import algorithm -from grumpy.pythonparser import ast +from grumpy_tools.compiler import expr +from grumpy_tools.compiler import util +from grumpy_tools.vendor.pythonparser import algorithm +from grumpy_tools.vendor.pythonparser import ast class ExprVisitor(algorithm.Visitor): diff --git a/grumpy-runtime-src/compiler/expr_visitor_test.py b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py similarity index 99% rename from grumpy-runtime-src/compiler/expr_visitor_test.py rename to grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py index 08e392ea..31c998d3 100644 --- a/grumpy-runtime-src/compiler/expr_visitor_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py @@ -26,7 +26,7 @@ from grumpy.compiler import imputil from grumpy.compiler import shard_test from grumpy.compiler import stmt -from grumpy import pythonparser +from grumpy.vendor import pythonparser def _MakeExprTest(expr): diff --git a/grumpy-runtime-src/compiler/imputil.py b/grumpy-tools-src/grumpy_tools/compiler/imputil.py similarity index 98% rename from grumpy-runtime-src/compiler/imputil.py rename to grumpy-tools-src/grumpy_tools/compiler/imputil.py index 811a6555..6daafc7d 100644 --- a/grumpy-runtime-src/compiler/imputil.py +++ b/grumpy-tools-src/grumpy_tools/compiler/imputil.py @@ -24,10 +24,10 @@ import os import os.path -from grumpy.compiler import util -from grumpy import pythonparser -from grumpy.pythonparser import algorithm -from grumpy.pythonparser import ast +from grumpy_tools.compiler import util +from grumpy_tools.vendor import pythonparser +from grumpy_tools.vendor.pythonparser import algorithm +from grumpy_tools.vendor.pythonparser import ast _NATIVE_MODULE_PREFIX = '__go__/' diff --git a/grumpy-runtime-src/compiler/imputil_test.py b/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py similarity index 99% rename from grumpy-runtime-src/compiler/imputil_test.py rename to grumpy-tools-src/grumpy_tools/compiler/imputil_test.py index 600afdf0..2fce6bd5 100644 --- a/grumpy-runtime-src/compiler/imputil_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py @@ -27,7 +27,7 @@ from grumpy.compiler import imputil from grumpy.compiler import util -from grumpy import pythonparser +from grumpy.vendor import pythonparser class ImportVisitorTest(unittest.TestCase): diff --git a/grumpy-runtime-src/compiler/shard_test.py b/grumpy-tools-src/grumpy_tools/compiler/shard_test.py similarity index 100% rename from grumpy-runtime-src/compiler/shard_test.py rename to grumpy-tools-src/grumpy_tools/compiler/shard_test.py diff --git a/grumpy-runtime-src/compiler/stmt.py b/grumpy-tools-src/grumpy_tools/compiler/stmt.py similarity index 99% rename from grumpy-runtime-src/compiler/stmt.py rename to grumpy-tools-src/grumpy_tools/compiler/stmt.py index 8daac1db..c02f2664 100644 --- a/grumpy-runtime-src/compiler/stmt.py +++ b/grumpy-tools-src/grumpy_tools/compiler/stmt.py @@ -21,13 +21,13 @@ import string import textwrap -from grumpy.compiler import block -from grumpy.compiler import expr -from grumpy.compiler import expr_visitor -from grumpy.compiler import imputil -from grumpy.compiler import util -from grumpy.pythonparser import algorithm -from grumpy.pythonparser import ast +from grumpy_tools.compiler import block +from grumpy_tools.compiler import expr +from grumpy_tools.compiler import expr_visitor +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util +from grumpy_tools.vendor.pythonparser import algorithm +from grumpy_tools.vendor.pythonparser import ast _NATIVE_TYPE_PREFIX = 'type_' diff --git a/grumpy-runtime-src/compiler/stmt_test.py b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py similarity index 99% rename from grumpy-runtime-src/compiler/stmt_test.py rename to grumpy-tools-src/grumpy_tools/compiler/stmt_test.py index 5f4cb0f5..2db9b623 100644 --- a/grumpy-runtime-src/compiler/stmt_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py @@ -28,8 +28,8 @@ from grumpy.compiler import shard_test from grumpy.compiler import stmt from grumpy.compiler import util -from grumpy import pythonparser -from grumpy.pythonparser import ast +from grumpy.vendor import pythonparser +from grumpy.vendor.pythonparser import ast class StatementVisitorTest(unittest.TestCase): diff --git a/grumpy-runtime-src/compiler/util.py b/grumpy-tools-src/grumpy_tools/compiler/util.py similarity index 96% rename from grumpy-runtime-src/compiler/util.py rename to grumpy-tools-src/grumpy_tools/compiler/util.py index e70ce527..3d517b67 100644 --- a/grumpy-runtime-src/compiler/util.py +++ b/grumpy-tools-src/grumpy_tools/compiler/util.py @@ -20,11 +20,14 @@ import codecs import contextlib -import cStringIO import string import StringIO import textwrap +try: + string.letters +except AttributeError: + string.letters = string.ascii_letters _SIMPLE_CHARS = set(string.digits + string.letters + string.punctuation + " ") _ESCAPES = {'\t': r'\t', '\r': r'\r', '\n': r'\n', '"': r'\"', '\\': r'\\'} @@ -62,7 +65,7 @@ class Writer(object): """Utility class for writing blocks of Go code to a file-like object.""" def __init__(self, out=None): - self.out = codecs.getwriter('utf8')(out or cStringIO.StringIO()) + self.out = codecs.getwriter('utf8')(out or StringIO.StringIO()) self.indent_level = 0 def getvalue(self): diff --git a/grumpy-runtime-src/compiler/util_test.py b/grumpy-tools-src/grumpy_tools/compiler/util_test.py similarity index 100% rename from grumpy-runtime-src/compiler/util_test.py rename to grumpy-tools-src/grumpy_tools/compiler/util_test.py diff --git a/grumpy-tools-src/grumpy_tools/coverparse.py b/grumpy-tools-src/grumpy_tools/coverparse.py new file mode 100755 index 00000000..d8b72aba --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/coverparse.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Parse a Go coverage file and prints a message for lines missing coverage.""" + +import collections +import re +import sys + + +cover_re = re.compile(r'([^:]+):(\d+)\.\d+,(\d+).\d+ \d+ (\d+)$') + + +def _ParseCover(f): + """Return a dict of sets with uncovered line numbers from a Go cover file.""" + uncovered = collections.defaultdict(set) + for line in f: + match = cover_re.match(line.rstrip()) + if not match: + raise RuntimeError('invalid coverage line: {!r}'.format(line)) + filename, line_start, line_end, count = match.groups() + if not int(count): + for i in xrange(int(line_start), int(line_end) + 1): + uncovered[filename].add(i) + return uncovered + + +def main(): + with open(sys.argv[1]) as f: + f.readline() + uncovered = _ParseCover(f) + for filename in sorted(uncovered.keys()): + for lineno in sorted(uncovered[filename]): + print '{}:{}'.format(filename, lineno) + + +if __name__ == '__main__': + main() diff --git a/grumpy-tools-src/grumpy_tools/diffrange.py b/grumpy-tools-src/grumpy_tools/diffrange.py new file mode 100755 index 00000000..ea60fb0f --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/diffrange.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Convert a unified diff into a list of modified files and line numbers.""" + +import sys + + +class _LineBuffer(object): + """Iterator over lines in a file supporting one-step rewind.""" + + def __init__(self, f): + self._f = f + self._prev = None + self._next = None + + def __iter__(self): + return self + + def next(self): + if self._next is not None: + cur = self._next + else: + cur = self._f.readline() + if not cur: + raise StopIteration + self._next = None + self._prev = cur + return cur + + def Rewind(self): + assert self._prev is not None + self._next = self._prev + self._prev = None + + +def _ReadHunks(buf): + for line in buf: + if not line.startswith('@@'): + break + base = int(line.split()[2].split(',')[0]) + for offset in _ReadHunkBody(buf): + yield base + offset + + +def _ReadHunkBody(buf): + n = 0 + for line in buf: + prefix = line[0] + if prefix == ' ': + n += 1 + elif prefix == '+': + yield n + n += 1 + elif prefix != '-' or line.startswith('---'): + buf.Rewind() + break + + +def main(): + buf = _LineBuffer(sys.stdin) + for line in buf: + if line.startswith('+++'): + filename = line.split()[1] + for n in _ReadHunks(buf): + print '{}:{}'.format(filename, n) + + +if __name__ == '__main__': + main() diff --git a/grumpy-tools-src/grumpy_tools/genmake.py b/grumpy-tools-src/grumpy_tools/genmake.py new file mode 100755 index 00000000..c13465a5 --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/genmake.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Generate a Makefile for Python targets in a GOPATH directory.""" + +import argparse +import os +import subprocess +import sys + + +parser = argparse.ArgumentParser() +parser.add_argument('dir', help='GOPATH dir to scan for Python modules') +parser.add_argument('-all_target', default='all', + help='make target that will build all modules') + + +def _PrintRule(target, prereqs, rules): + print '{}: {}'.format(target, ' '.join(prereqs)) + if rules: + print '\t@mkdir -p $(@D)' + for rule in rules: + print '\t@{}'.format(rule) + print + + +def main(args): + try: + proc = subprocess.Popen('go env GOOS GOARCH', shell=True, + stdout=subprocess.PIPE) + except OSError as e: + print >> sys.stderr, str(e) + return 1 + out, _ = proc.communicate() + if proc.returncode: + print >> sys.stderr, 'go exited with status: {}'.format(proc.returncode) + return 1 + goos, goarch = out.split() + + if args.all_target: + print '{}:\n'.format(args.all_target) + + gopath = os.path.normpath(args.dir) + pkg_dir = os.path.join(gopath, 'pkg', '{}_{}'.format(goos, goarch)) + pydir = os.path.join(gopath, 'src', '__python__') + for dirpath, _, filenames in os.walk(pydir): + for filename in filenames: + if not filename.endswith('.py'): + continue + basename = os.path.relpath(dirpath, pydir) + if filename != '__init__.py': + basename = os.path.normpath( + os.path.join(basename, filename[:-3])) + modname = basename.replace(os.sep, '.') + ar_name = os.path.join(pkg_dir, '__python__', basename + '.a') + go_file = os.path.join(pydir, basename, 'module.go') + _PrintRule(go_file, + [os.path.join(dirpath, filename)], + ['grumpc -modname={} $< > $@'.format(modname)]) + recipe = (r"""pydeps -modname=%s $< | awk '{gsub(/\./, "/", $$0); """ + r"""print "%s: %s/__python__/" $$0 ".a"}' > $@""") + dep_file = os.path.join(pydir, basename, 'module.d') + _PrintRule(dep_file, [os.path.join(dirpath, filename)], + [recipe % (modname, ar_name, pkg_dir)]) + go_package = '__python__/' + basename.replace(os.sep, '/') + recipe = 'go tool compile -o $@ -p {} -complete -I {} -pack $<' + _PrintRule(ar_name, [go_file], [recipe.format(go_package, pkg_dir)]) + if args.all_target: + _PrintRule(args.all_target, [ar_name], []) + print '-include {}\n'.format(dep_file) + + +if __name__ == '__main__': + sys.exit(main(parser.parse_args())) diff --git a/grumpy-tools-src/grumpy_tools/grumpc.py b/grumpy-tools-src/grumpy_tools/grumpc.py new file mode 100755 index 00000000..42c120c9 --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/grumpc.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# coding=utf-8 + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""A Python -> Go transcompiler.""" + +from __future__ import unicode_literals + +import argparse +import os +import sys +import textwrap + +from .compiler import block +from .compiler import imputil +from .compiler import stmt +from .compiler import util +from .vendor import pythonparser + + +def main(script=None, modname=None): + # import wdb; wdb.set_trace() + assert script and modname, 'Script "%s" or Modname "%s" is empty' % (script,modname) + + gopath = os.getenv('GOPATH', None) + if not gopath: + print >> sys.stderr, 'GOPATH not set' + return 1 + + with open(script) as py_file: + py_contents = py_file.read() + try: + mod = pythonparser.parse(py_contents) + except SyntaxError as e: + print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( + e.filename, e.lineno, e.text) + return 2 + + # Do a pass for compiler directives from `from __future__ import *` statements + try: + future_node, future_features = imputil.parse_future_features(mod) + except util.CompileError as e: + print >> sys.stderr, str(e) + return 2 + + importer = imputil.Importer(gopath, modname, script, + future_features.absolute_import) + full_package_name = modname.replace('.', '/') + mod_block = block.ModuleBlock(importer, full_package_name, script, + py_contents, future_features) + + visitor = stmt.StatementVisitor(mod_block, future_node) + # Indent so that the module body is aligned with the goto labels. + with visitor.writer.indent_block(): + try: + visitor.visit(mod) + except util.ParseError as e: + print >> sys.stderr, str(e) + return 2 + + writer = util.Writer(sys.stdout) + tmpl = textwrap.dedent("""\ + package $package + import πg "grumpy" + var Code *πg.Code + func init() { + \tCode = πg.NewCode("", $script, nil, 0, func(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) { + \t\tvar πR *πg.Object; _ = πR + \t\tvar πE *πg.BaseException; _ = πE""") + writer.write_tmpl(tmpl, package=modname.split('.')[-1], + script=util.go_str(script)) + with writer.indent_block(2): + for s in sorted(mod_block.strings): + writer.write('ß{} := πg.InternStr({})'.format(s, util.go_str(s))) + writer.write_temp_decls(mod_block) + writer.write_block(mod_block, visitor.writer.getvalue()) + writer.write_tmpl(textwrap.dedent("""\ + \t\treturn nil, πE + \t}) + \tπg.RegisterModule($modname, Code) + }"""), modname=util.go_str(modname)) + return 0 diff --git a/grumpy-tools-src/grumpy_tools/grumprun.py b/grumpy-tools-src/grumpy_tools/grumprun.py new file mode 100755 index 00000000..3de483dc --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/grumprun.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""grumprun compiles and runs a snippet of Python using Grumpy. + +Usage: $ grumprun -m # Run the named module. + $ echo 'print "hola!"' | grumprun # Execute Python code from stdin. +""" + +import argparse +import os +import random +import shutil +import string +import subprocess +import sys +import tempfile + +from .compiler import imputil + + +module_tmpl = string.Template("""\ +package main +import ( +\t"os" +\t"grumpy" +\tmod "$package" +$imports +) +func main() { +\tgrumpy.ImportModule(grumpy.NewRootFrame(), "traceback") +\tos.Exit(grumpy.RunMain(mod.Code)) +} +""") + + +def main(modname=None): + gopath = os.getenv('GOPATH', None) + if not gopath: + print >> sys.stderr, 'GOPATH not set' + return 1 + + workdir = tempfile.mkdtemp() + try: + if modname: + # Find the script associated with the given module. + for d in gopath.split(os.pathsep): + script = imputil.find_script( + os.path.join(d, 'src', '__python__'), modname) + if script: + break + else: + print >> sys.stderr, "can't find module", modname + return 1 + else: + # Generate a dummy python script on the GOPATH. + modname = ''.join(random.choice(string.ascii_letters) for _ in range(16)) + py_dir = os.path.join(workdir, 'src', '__python__') + mod_dir = os.path.join(py_dir, modname) + os.makedirs(mod_dir) + script = os.path.join(py_dir, 'module.py') + with open(script, 'w') as f: + f.write(sys.stdin.read()) + gopath = gopath + os.pathsep + workdir + os.putenv('GOPATH', gopath) + # Compile the dummy script to Go using grumpc. + fd = os.open(os.path.join(mod_dir, 'module.go'), os.O_WRONLY | os.O_CREAT) + try: + p = subprocess.Popen('grumpy transpile ' + script, stdout=fd, shell=True) + if p.wait(): + return 1 + finally: + os.close(fd) + + names = imputil.calculate_transitive_deps(modname, script, gopath) + # Make sure traceback is available in all Python binaries. + names.add('traceback') + go_main = os.path.join(workdir, 'main.go') + package = _package_name(modname) + imports = ''.join('\t_ "' + _package_name(name) + '"\n' for name in names) + with open(go_main, 'w') as f: + f.write(module_tmpl.substitute(package=package, imports=imports)) + return subprocess.Popen('go run ' + go_main, shell=True).wait() + finally: + shutil.rmtree(workdir) + + +def _package_name(modname): + if modname.startswith('__go__/'): + return '__python__/' + modname + return '__python__/' + modname.replace('.', '/') diff --git a/grumpy-tools-src/grumpy_tools/grumpy_tools.py b/grumpy-tools-src/grumpy_tools/grumpy_tools.py new file mode 100644 index 00000000..7fbbae4f --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/grumpy_tools.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +"""Main module.""" diff --git a/grumpy-tools-src/grumpy_tools/pydeps.py b/grumpy-tools-src/grumpy_tools/pydeps.py new file mode 100755 index 00000000..d72dc9fa --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/pydeps.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Outputs names of modules imported by a script.""" + +import argparse +import os +import sys + +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util + + +parser = argparse.ArgumentParser() +parser.add_argument('script', help='Python source filename') +parser.add_argument('-modname', default='__main__', help='Python module name') + + +def main(args): + gopath = os.getenv('GOPATH', None) + if not gopath: + print >> sys.stderr, 'GOPATH not set' + return 1 + + try: + imports = imputil.collect_imports(args.modname, args.script, gopath) + except SyntaxError as e: + print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( + e.filename, e.lineno, e.text) + return 2 + except util.CompileError as e: + print >> sys.stderr, str(e) + return 2 + + names = set([args.modname]) + for imp in imports: + if imp.is_native: + print imp.name + else: + parts = imp.name.split('.') + # Iterate over all packages and the leaf module. + for i in xrange(len(parts)): + name = '.'.join(parts[:i+1]) + if name not in names: + names.add(name) + print name + + +if __name__ == '__main__': + main(parser.parse_args()) diff --git a/grumpy-tools-src/grumpy_tools/vendor/__init__.py b/grumpy-tools-src/grumpy_tools/vendor/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/grumpy-runtime-src/third_party/pythonparser/LICENSE.txt b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/LICENSE.txt similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/LICENSE.txt rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/LICENSE.txt diff --git a/grumpy-runtime-src/third_party/pythonparser/README.md b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/README.md similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/README.md rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/README.md diff --git a/grumpy-runtime-src/third_party/pythonparser/__init__.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/__init__.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/__init__.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/__init__.py diff --git a/grumpy-runtime-src/third_party/pythonparser/algorithm.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/algorithm.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/algorithm.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/algorithm.py diff --git a/grumpy-runtime-src/third_party/pythonparser/ast.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/ast.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/ast.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/ast.py diff --git a/grumpy-runtime-src/third_party/pythonparser/diagnostic.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/diagnostic.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/diagnostic.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/diagnostic.py diff --git a/grumpy-runtime-src/third_party/pythonparser/lexer.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/lexer.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/lexer.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/lexer.py diff --git a/grumpy-runtime-src/third_party/pythonparser/parser.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/parser.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/parser.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/parser.py diff --git a/grumpy-runtime-src/third_party/pythonparser/source.py b/grumpy-tools-src/grumpy_tools/vendor/pythonparser/source.py similarity index 100% rename from grumpy-runtime-src/third_party/pythonparser/source.py rename to grumpy-tools-src/grumpy_tools/vendor/pythonparser/source.py diff --git a/grumpy-tools-src/tests/test_grumpy_tools.py b/grumpy-tools-src/tests/test_grumpy_tools.py new file mode 100644 index 00000000..e8f4f333 --- /dev/null +++ b/grumpy-tools-src/tests/test_grumpy_tools.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Tests for `grumpy_tools` package.""" + +import pytest + +from click.testing import CliRunner + +from grumpy import cli + + +@pytest.fixture +def response(): + """Sample pytest fixture. + + See more at: http://doc.pytest.org/en/latest/fixture.html + """ + # import requests + # return requests.get('https://github.com/audreyr/cookiecutter-pypackage') + + +def test_content(response): + """Sample pytest test function with the pytest fixture as an argument.""" + # from bs4 import BeautifulSoup + # assert 'GitHub' in BeautifulSoup(response.content).title.string + + +def test_command_line_interface(): + """Test the CLI.""" + runner = CliRunner() + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert 'Usage: ' in result.output + help_result = runner.invoke(cli.main, ['--help']) + assert help_result.exit_code == 0 + assert '--help Show this message and exit.' in help_result.output diff --git a/setup.py b/setup.py index 301133af..76e65db2 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ ), entry_points={ 'console_scripts': [ - 'grumpy=grumpy.cli:main', + 'grumpy=grumpy_tools.cli:main', ], }, include_package_data=True, From 8830b445825c538ac6fc66f2b3e89c98cb58b000 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 17:47:22 -0300 Subject: [PATCH 05/73] Use installed CLI instead of /bin/grump{c,run} --- grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py | 2 +- grumpy-tools-src/grumpy_tools/compiler/stmt_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py index 31c998d3..6eab0e92 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py @@ -237,7 +237,7 @@ def _ParseAndVisitExpr(expr): def _GrumpRun(cmd): - p = subprocess.Popen(['grumprun'], stdin=subprocess.PIPE, + p = subprocess.Popen(['grumpy', 'run'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = p.communicate(cmd) return p.returncode, out diff --git a/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py index 2db9b623..f9461a41 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py @@ -545,7 +545,7 @@ def _ParseAndVisit(source): def _GrumpRun(cmd): - p = subprocess.Popen(['grumprun'], stdin=subprocess.PIPE, + p = subprocess.Popen(['grumpy', 'run'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = p.communicate(cmd) return p.returncode, out From 4e4db780c05bb4dbcea31523360c5faef040a881 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 17:53:55 -0300 Subject: [PATCH 06/73] tools grump{c,run} should be called via CLI: grumpc -> grumpy translate grumprun -> grumpy run --- grumpy-runtime-src/tools/grumpc | 107 +--------------------- grumpy-runtime-src/tools/grumprun | 113 +----------------------- grumpy-tools-src/grumpy_tools/grumpc.py | 1 - 3 files changed, 4 insertions(+), 217 deletions(-) diff --git a/grumpy-runtime-src/tools/grumpc b/grumpy-runtime-src/tools/grumpc index 53837738..2e463133 100755 --- a/grumpy-runtime-src/tools/grumpc +++ b/grumpy-runtime-src/tools/grumpc @@ -1,106 +1,3 @@ -#!/usr/bin/env python -# coding=utf-8 +#!/usr/bin/env bash -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""A Python -> Go transcompiler.""" - -from __future__ import unicode_literals - -import argparse -import os -import sys -import textwrap - -from grumpy.compiler import block -from grumpy.compiler import imputil -from grumpy.compiler import stmt -from grumpy.compiler import util -from grumpy import pythonparser - - -parser = argparse.ArgumentParser() -parser.add_argument('script', help='Python source filename') -parser.add_argument('-modname', default='__main__', help='Python module name') - - -def main(args): - for arg in ('script', 'modname'): - if not getattr(args, arg, None): - print >> sys.stderr, '{} arg must not be empty'.format(arg) - return 1 - - gopath = os.getenv('GOPATH', None) - if not gopath: - print >> sys.stderr, 'GOPATH not set' - return 1 - - with open(args.script) as py_file: - py_contents = py_file.read() - try: - mod = pythonparser.parse(py_contents) - except SyntaxError as e: - print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( - e.filename, e.lineno, e.text) - return 2 - - # Do a pass for compiler directives from `from __future__ import *` statements - try: - future_node, future_features = imputil.parse_future_features(mod) - except util.CompileError as e: - print >> sys.stderr, str(e) - return 2 - - importer = imputil.Importer(gopath, args.modname, args.script, - future_features.absolute_import) - full_package_name = args.modname.replace('.', '/') - mod_block = block.ModuleBlock(importer, full_package_name, args.script, - py_contents, future_features) - - visitor = stmt.StatementVisitor(mod_block, future_node) - # Indent so that the module body is aligned with the goto labels. - with visitor.writer.indent_block(): - try: - visitor.visit(mod) - except util.ParseError as e: - print >> sys.stderr, str(e) - return 2 - - writer = util.Writer(sys.stdout) - tmpl = textwrap.dedent("""\ - package $package - import πg "grumpy" - var Code *πg.Code - func init() { - \tCode = πg.NewCode("", $script, nil, 0, func(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) { - \t\tvar πR *πg.Object; _ = πR - \t\tvar πE *πg.BaseException; _ = πE""") - writer.write_tmpl(tmpl, package=args.modname.split('.')[-1], - script=util.go_str(args.script)) - with writer.indent_block(2): - for s in sorted(mod_block.strings): - writer.write('ß{} := πg.InternStr({})'.format(s, util.go_str(s))) - writer.write_temp_decls(mod_block) - writer.write_block(mod_block, visitor.writer.getvalue()) - writer.write_tmpl(textwrap.dedent("""\ - \t\treturn nil, πE - \t}) - \tπg.RegisterModule($modname, Code) - }"""), modname=util.go_str(args.modname)) - return 0 - - -if __name__ == '__main__': - sys.exit(main(parser.parse_args())) +exec grumpy transpile $@ diff --git a/grumpy-runtime-src/tools/grumprun b/grumpy-runtime-src/tools/grumprun index fd237713..a2363929 100755 --- a/grumpy-runtime-src/tools/grumprun +++ b/grumpy-runtime-src/tools/grumprun @@ -1,112 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env bash -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""grumprun compiles and runs a snippet of Python using Grumpy. - -Usage: $ grumprun -m # Run the named module. - $ echo 'print "hola!"' | grumprun # Execute Python code from stdin. -""" - -import argparse -import os -import random -import shutil -import string -import subprocess -import sys -import tempfile - -from grumpy.compiler import imputil - - -parser = argparse.ArgumentParser() -parser.add_argument('-m', '--modname', help='Run the named module') - -module_tmpl = string.Template("""\ -package main -import ( -\t"os" -\t"grumpy" -\tmod "$package" -$imports -) -func main() { -\tgrumpy.ImportModule(grumpy.NewRootFrame(), "traceback") -\tos.Exit(grumpy.RunMain(mod.Code)) -} -""") - - -def main(args): - gopath = os.getenv('GOPATH', None) - if not gopath: - print >> sys.stderr, 'GOPATH not set' - return 1 - - modname = args.modname - workdir = tempfile.mkdtemp() - try: - if modname: - # Find the script associated with the given module. - for d in gopath.split(os.pathsep): - script = imputil.find_script( - os.path.join(d, 'src', '__python__'), modname) - if script: - break - else: - print >> sys.stderr, "can't find module", modname - return 1 - else: - # Generate a dummy python script on the GOPATH. - modname = ''.join(random.choice(string.ascii_letters) for _ in range(16)) - py_dir = os.path.join(workdir, 'src', '__python__') - mod_dir = os.path.join(py_dir, modname) - os.makedirs(mod_dir) - script = os.path.join(py_dir, 'module.py') - with open(script, 'w') as f: - f.write(sys.stdin.read()) - gopath = gopath + os.pathsep + workdir - os.putenv('GOPATH', gopath) - # Compile the dummy script to Go using grumpc. - fd = os.open(os.path.join(mod_dir, 'module.go'), os.O_WRONLY | os.O_CREAT) - try: - p = subprocess.Popen('grumpc ' + script, stdout=fd, shell=True) - if p.wait(): - return 1 - finally: - os.close(fd) - - names = imputil.calculate_transitive_deps(modname, script, gopath) - # Make sure traceback is available in all Python binaries. - names.add('traceback') - go_main = os.path.join(workdir, 'main.go') - package = _package_name(modname) - imports = ''.join('\t_ "' + _package_name(name) + '"\n' for name in names) - with open(go_main, 'w') as f: - f.write(module_tmpl.substitute(package=package, imports=imports)) - return subprocess.Popen('go run ' + go_main, shell=True).wait() - finally: - shutil.rmtree(workdir) - - -def _package_name(modname): - if modname.startswith('__go__/'): - return '__python__/' + modname - return '__python__/' + modname.replace('.', '/') - - -if __name__ == '__main__': - sys.exit(main(parser.parse_args())) +exec grumpy run $@ diff --git a/grumpy-tools-src/grumpy_tools/grumpc.py b/grumpy-tools-src/grumpy_tools/grumpc.py index 42c120c9..4ea6440a 100755 --- a/grumpy-tools-src/grumpy_tools/grumpc.py +++ b/grumpy-tools-src/grumpy_tools/grumpc.py @@ -32,7 +32,6 @@ def main(script=None, modname=None): - # import wdb; wdb.set_trace() assert script and modname, 'Script "%s" or Modname "%s" is empty' % (script,modname) gopath = os.getenv('GOPATH', None) From a0445e3fcc3f874f3640c65179495b285ede280e Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 17:58:02 -0300 Subject: [PATCH 07/73] Give credit --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 76e65db2..afa87bef 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", - maintainer="Alan Justino", + maintainer="Alan Justino et al.", maintainer_email="alan.justino@yahoo.com.br", url='https://github.com/alanjds/grumpy', package_dir={'':'grumpy-tools-src'}, From 6d97fddb693729f0f35a52cc4eb415965f05482c Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 18:05:24 -0300 Subject: [PATCH 08/73] Docs update on how to install/use the tools --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 13ec575d..20720e53 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,17 @@ There are three basic categories of incomplete functionality: ## Running Grumpy Programs +### Pre-requisites + +The Grumpy Transpiler and Runner tools are provided as a Python Package. +All of the commands below are assumed to be run from the +root directory of the Grumpy source code distribution. Install the package: + +``` +pip2 install -U pip setuptools +python2 setup.py develop +``` + ### Method 1: make run: The simplest way to execute a Grumpy program is to use `make run`, which wraps a From ea84b3926805920c397e1f0dfba946c589a6c052 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 18:08:30 -0300 Subject: [PATCH 09/73] Oops: Correct path --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index afa87bef..f0375b9f 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ author="Dylan Trotter et al.", maintainer="Alan Justino et al.", maintainer_email="alan.justino@yahoo.com.br", - url='https://github.com/alanjds/grumpy', + url='https://github.com/google/grumpy', package_dir={'':'grumpy-tools-src'}, packages=find_packages( 'grumpy-tools-src', From 818959becfdd279bf31adc1d4ea632c7b694bb99 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 18:25:57 -0300 Subject: [PATCH 10/73] Preparing to install Runtime as a package --- setup.py | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index f0375b9f..df86ba7e 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ # TODO: Put package test requirements here ] -setup( +COMMON_OPTIONS = dict( name='grumpy-tools', version='0.1.0', description="Grumpy Runtime & Transpiler", @@ -48,16 +48,6 @@ maintainer="Alan Justino et al.", maintainer_email="alan.justino@yahoo.com.br", url='https://github.com/google/grumpy', - package_dir={'':'grumpy-tools-src'}, - packages=find_packages( - 'grumpy-tools-src', - exclude=["*.tests", "*.tests.*", "tests.*", "tests"], - ), - entry_points={ - 'console_scripts': [ - 'grumpy=grumpy_tools.cli:main', - ], - }, include_package_data=True, install_requires=requirements, license="Apache Software License 2.0", @@ -76,3 +66,35 @@ tests_require=test_requirements, setup_requires=setup_requirements, ) + + +GRUMPY_TOOLS_OPTIONS = dict( + package_dir={'':'grumpy-tools-src'}, + packages=find_packages( + 'grumpy-tools-src', + exclude=["*.tests", "*.tests.*", "tests.*", "tests"], + ), + entry_points={ + 'console_scripts': [ + 'grumpy=grumpy_tools.cli:main', + ], + }, +) +GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) + + +GRUMPY_RUNTIME_OPTIONS = dict( + package_dir={'':'grumpy-runtime-src'}, + packages=find_packages( + 'grumpy-runtime-src', + exclude=["*.tests", "*.tests.*", "tests.*", "tests"], + ), +) +GRUMPY_RUNTIME_OPTIONS.update(COMMON_OPTIONS) + + +## Just the "tools" +setup(**GRUMPY_TOOLS_OPTIONS) + +# ## Just the "runtime" +# setup(**GRUMPY_RUNTIME_OPTIONS) From ec7d02a55f13fe131808be7748fbdcba05c3f789 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 18:27:55 -0300 Subject: [PATCH 11/73] Docs updated --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 20720e53..4f690fe4 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ the code under Grumpy. All of the commands below are assumed to be run from the root directory of the Grumpy source code distribution: ``` +cd grumpy-runtime-src echo "print 'hello, world'" | make run ``` @@ -92,6 +93,7 @@ The first step is to set up the shell so that the Grumpy toolchain and libraries can be found. From the root directory of the Grumpy source distribution run: ``` +cd grumpy-runtime-src make export PATH=$PWD/build/bin:$PATH export GOPATH=$PWD/build @@ -102,18 +104,21 @@ You will know things are working if you see the expected output from this command: ``` +cd grumpy-runtime-src echo 'import sys; print sys.version' | grumprun ``` Next, we will write our simple Python module into the \_\_python\_\_ directory: ``` +cd grumpy-runtime-src echo 'def hello(): print "hello, world"' > $GOPATH/src/__python__/hello.py ``` To build a Go package from our Python script, run the following: ``` +cd grumpy-runtime-src mkdir -p $GOPATH/src/__python__/hello grumpc -modname=hello $GOPATH/src/__python__/hello.py > \ $GOPATH/src/__python__/hello/module.go @@ -124,6 +129,7 @@ You should now be able to build a Go program that imports the package that are built using grumprun: ``` +cd grumpy-runtime-src echo 'from hello import hello; hello()' | grumprun ``` From 3435c556d8045d42db34ae0418a0df7bbd13e857 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 18:32:38 -0300 Subject: [PATCH 12/73] Fix imports --- grumpy-runtime-src/tools/pydeps | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grumpy-runtime-src/tools/pydeps b/grumpy-runtime-src/tools/pydeps index f0dd45f7..d72dc9fa 100755 --- a/grumpy-runtime-src/tools/pydeps +++ b/grumpy-runtime-src/tools/pydeps @@ -20,8 +20,8 @@ import argparse import os import sys -from grumpy.compiler import imputil -from grumpy.compiler import util +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util parser = argparse.ArgumentParser() From fafdddeb7e140d8fe7edb745bf6e6738aca4db41 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 19:22:16 -0300 Subject: [PATCH 13/73] trigger the ci From ca7f1d978abc5c12dacd5ef17443a212500533c0 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 20:21:28 -0300 Subject: [PATCH 14/73] Inform Travis of the new package --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7f0c7112..70d00c07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ os: before_script: - rvm get head || true # https://github.com/travis-ci/travis-ci/issues/6307 - set -e + - python setup.py develop + - cd grumpy-runtime-src # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. script: make gofmt lint && make -j2 test From 262c7b272dbc026aa5aaf7e23ef5719511172c31 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 17 Mar 2018 20:43:40 -0300 Subject: [PATCH 15/73] should pip install --user on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 70d00c07..f6057c90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ os: before_script: - rvm get head || true # https://github.com/travis-ci/travis-ci/issues/6307 - set -e - - python setup.py develop + - pip2 install --user . - cd grumpy-runtime-src # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. From 12194836234527d3433f62e7448588ffcf77aca0 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sun, 18 Mar 2018 23:21:58 -0300 Subject: [PATCH 16/73] Poking around for Travis bless --- grumpy-runtime-src/tools/grumpc | 4 +++- grumpy-runtime-src/tools/grumprun | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grumpy-runtime-src/tools/grumpc b/grumpy-runtime-src/tools/grumpc index 2e463133..8f1243a2 100755 --- a/grumpy-runtime-src/tools/grumpc +++ b/grumpy-runtime-src/tools/grumpc @@ -1,3 +1,5 @@ -#!/usr/bin/env bash +#!/bin/bash + +set -v exec grumpy transpile $@ diff --git a/grumpy-runtime-src/tools/grumprun b/grumpy-runtime-src/tools/grumprun index a2363929..6a431ead 100755 --- a/grumpy-runtime-src/tools/grumprun +++ b/grumpy-runtime-src/tools/grumprun @@ -1,3 +1,5 @@ -#!/usr/bin/env bash +#!/bin/bash + +set -v exec grumpy run $@ From 796ba6fdc40ce9d19008392b17fca0065fc9d587 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 19 Mar 2018 00:29:44 -0300 Subject: [PATCH 17/73] do not pylint bash files --- grumpy-runtime-src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/Makefile b/grumpy-runtime-src/Makefile index 9398f9e7..2eab9dd6 100644 --- a/grumpy-runtime-src/Makefile +++ b/grumpy-runtime-src/Makefile @@ -246,7 +246,7 @@ $(PYLINT_BIN): @cd build/third_party && curl -sL https://pypi.io/packages/source/p/pylint/pylint-1.6.4.tar.gz | tar -zx @cd build/third_party/pylint-1.6.4 && $(PYTHON) setup.py install --prefix $(ROOT_DIR)/build -pylint: $(PYLINT_BIN) $(COMPILER_SRCS) $(PYTHONPARSER_SRCS) $(COMPILER_BIN) $(RUNNER_BIN) $(TOOL_BINS) +pylint: $(PYLINT_BIN) $(COMPILER_SRCS) $(PYTHONPARSER_SRCS) $(TOOL_BINS) @$(PYTHON) $(PYLINT_BIN) $(COMPILER_SRCS) $(COMPILER_BIN) $(RUNNER_BIN) $(TOOL_BINS) lint: golint pylint From 2fb448191cd94998eff9dbf21996a3e320da19de Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 19 Mar 2018 00:29:44 -0300 Subject: [PATCH 18/73] do not pylint bash files --- grumpy-runtime-src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grumpy-runtime-src/Makefile b/grumpy-runtime-src/Makefile index 9398f9e7..c75d2115 100644 --- a/grumpy-runtime-src/Makefile +++ b/grumpy-runtime-src/Makefile @@ -246,8 +246,8 @@ $(PYLINT_BIN): @cd build/third_party && curl -sL https://pypi.io/packages/source/p/pylint/pylint-1.6.4.tar.gz | tar -zx @cd build/third_party/pylint-1.6.4 && $(PYTHON) setup.py install --prefix $(ROOT_DIR)/build -pylint: $(PYLINT_BIN) $(COMPILER_SRCS) $(PYTHONPARSER_SRCS) $(COMPILER_BIN) $(RUNNER_BIN) $(TOOL_BINS) - @$(PYTHON) $(PYLINT_BIN) $(COMPILER_SRCS) $(COMPILER_BIN) $(RUNNER_BIN) $(TOOL_BINS) +pylint: $(PYLINT_BIN) $(COMPILER_SRCS) $(PYTHONPARSER_SRCS) $(TOOL_BINS) + @$(PYTHON) $(PYLINT_BIN) $(COMPILER_SRCS) $(TOOL_BINS) lint: golint pylint From 70635505ab24dc4248ee12c807c80d0352d2b2d1 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 19 Mar 2018 12:27:49 -0300 Subject: [PATCH 19/73] No need to be that verbose anymore --- grumpy-runtime-src/tools/grumpc | 2 -- grumpy-runtime-src/tools/grumprun | 2 -- 2 files changed, 4 deletions(-) diff --git a/grumpy-runtime-src/tools/grumpc b/grumpy-runtime-src/tools/grumpc index 8f1243a2..64c0b7a1 100755 --- a/grumpy-runtime-src/tools/grumpc +++ b/grumpy-runtime-src/tools/grumpc @@ -1,5 +1,3 @@ #!/bin/bash -set -v - exec grumpy transpile $@ diff --git a/grumpy-runtime-src/tools/grumprun b/grumpy-runtime-src/tools/grumprun index 6a431ead..b96c2218 100755 --- a/grumpy-runtime-src/tools/grumprun +++ b/grumpy-runtime-src/tools/grumprun @@ -1,5 +1,3 @@ #!/bin/bash -set -v - exec grumpy run $@ From 19f84d4aeae521b3311f0d68564aff152972989b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 19 Mar 2018 18:56:36 -0300 Subject: [PATCH 20/73] Hacking to fix the `make test` --- grumpy-runtime-src/compiler | 1 + 1 file changed, 1 insertion(+) create mode 120000 grumpy-runtime-src/compiler diff --git a/grumpy-runtime-src/compiler b/grumpy-runtime-src/compiler new file mode 120000 index 00000000..e2993627 --- /dev/null +++ b/grumpy-runtime-src/compiler @@ -0,0 +1 @@ +../grumpy-tools-src/grumpy_tools/compiler/ \ No newline at end of file From 18f407a5f33f9efe7e44a1950234e22af2c05734 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 19 Mar 2018 20:17:13 -0300 Subject: [PATCH 21/73] Fixed tests import namespaces --- .../grumpy_tools/compiler/block_test.py | 8 ++++---- .../grumpy_tools/compiler/expr_visitor_test.py | 10 +++++----- .../grumpy_tools/compiler/imputil_test.py | 6 +++--- .../grumpy_tools/compiler/stmt_test.py | 14 +++++++------- .../grumpy_tools/compiler/util_test.py | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/grumpy-tools-src/grumpy_tools/compiler/block_test.py b/grumpy-tools-src/grumpy_tools/compiler/block_test.py index 7b045fa5..56e29d4b 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/block_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/block_test.py @@ -21,10 +21,10 @@ import textwrap import unittest -from grumpy.compiler import block -from grumpy.compiler import imputil -from grumpy.compiler import util -from grumpy.vendor import pythonparser +from grumpy_tools.compiler import block +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util +from grumpy_tools.vendor import pythonparser class PackageTest(unittest.TestCase): diff --git a/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py index 6eab0e92..5453847e 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/expr_visitor_test.py @@ -22,11 +22,11 @@ import textwrap import unittest -from grumpy.compiler import block -from grumpy.compiler import imputil -from grumpy.compiler import shard_test -from grumpy.compiler import stmt -from grumpy.vendor import pythonparser +from grumpy_tools.compiler import block +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import shard_test +from grumpy_tools.compiler import stmt +from grumpy_tools.vendor import pythonparser def _MakeExprTest(expr): diff --git a/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py b/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py index 2fce6bd5..932fb396 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/imputil_test.py @@ -25,9 +25,9 @@ import textwrap import unittest -from grumpy.compiler import imputil -from grumpy.compiler import util -from grumpy.vendor import pythonparser +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util +from grumpy_tools.vendor import pythonparser class ImportVisitorTest(unittest.TestCase): diff --git a/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py index f9461a41..aa766823 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/stmt_test.py @@ -23,13 +23,13 @@ import textwrap import unittest -from grumpy.compiler import block -from grumpy.compiler import imputil -from grumpy.compiler import shard_test -from grumpy.compiler import stmt -from grumpy.compiler import util -from grumpy.vendor import pythonparser -from grumpy.vendor.pythonparser import ast +from grumpy_tools.compiler import block +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import shard_test +from grumpy_tools.compiler import stmt +from grumpy_tools.compiler import util +from grumpy_tools.vendor import pythonparser +from grumpy_tools.vendor.pythonparser import ast class StatementVisitorTest(unittest.TestCase): diff --git a/grumpy-tools-src/grumpy_tools/compiler/util_test.py b/grumpy-tools-src/grumpy_tools/compiler/util_test.py index d129ffa8..a94999da 100644 --- a/grumpy-tools-src/grumpy_tools/compiler/util_test.py +++ b/grumpy-tools-src/grumpy_tools/compiler/util_test.py @@ -20,9 +20,9 @@ import unittest -from grumpy.compiler import block -from grumpy.compiler import imputil -from grumpy.compiler import util +from grumpy_tools.compiler import block +from grumpy_tools.compiler import imputil +from grumpy_tools.compiler import util class WriterTest(unittest.TestCase): From e97c50a28cf1044dfb2d3a5f107c57288fb5d8bd Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 20 Mar 2018 00:05:28 -0300 Subject: [PATCH 22/73] rvm (#6307) strikes back && On OSX do sudo, on Linux dont. rvm (#6307) strikes back && On OSX do sudo, on Linux dont. Found the culprit: rvm provides `cd` binary! See: https://github.com/touist/touist/commit/5d7a327043e26a0ecc0a04f0fd040899dec6f63f#diff-354f30a63fb0907d4ad57269548329e3R52 See: https://github.com/rvm/rvm/blob/ff63fa117bd05e581ecbf2b0378d9ddbb263deb1/scripts/cd#L14 See: https://github.com/travis-ci/travis-ci/issues/8703#issuecomment-343681281 and https://github.com/travis-ci/travis-ci/issues/8703#issuecomment-347881274 Install pip locally Fix: Travis on OSX swallows error logs See: https://github.com/travis-ci/travis-ci/issues/6018 "never use set -e directly in .travis.yml" See: https://github.com/travis-ci/docs-travis-ci-com/issues/1672#issuecomment-363232212 See: https://github.com/travis-ci/travis-ci/issues/6307#issuecomment-355956554 On OSX, do sudo. On Linux, dont. --- .travis.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f6057c90..1ec56655 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,16 @@ os: - linux - osx before_script: - - rvm get head || true # https://github.com/travis-ci/travis-ci/issues/6307 - - set -e - - pip2 install --user . - - cd grumpy-runtime-src + - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # https://github.com/travis-ci/travis-ci/issues/8920#issuecomment-352661024 # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. -script: make gofmt lint && make -j2 test -after_script: set +e +script: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi + - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi + - which grumpy + - cd grumpy-runtime-src + - make gofmt lint && make -j2 test + +# OSX swallows error logs: https://github.com/travis-ci/travis-ci/issues/6018 +after_error: + - echo "== End of test log =="" From 839d66ceabdb1469bc93da149e00197321aa108f Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 22 Mar 2018 11:26:00 -0300 Subject: [PATCH 23/73] Opening room for Git to work w/ pydeps on the future --- grumpy-tools-src/grumpy_tools/pydeps.py | 63 ------------------------- 1 file changed, 63 deletions(-) delete mode 100755 grumpy-tools-src/grumpy_tools/pydeps.py diff --git a/grumpy-tools-src/grumpy_tools/pydeps.py b/grumpy-tools-src/grumpy_tools/pydeps.py deleted file mode 100755 index d72dc9fa..00000000 --- a/grumpy-tools-src/grumpy_tools/pydeps.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Outputs names of modules imported by a script.""" - -import argparse -import os -import sys - -from grumpy_tools.compiler import imputil -from grumpy_tools.compiler import util - - -parser = argparse.ArgumentParser() -parser.add_argument('script', help='Python source filename') -parser.add_argument('-modname', default='__main__', help='Python module name') - - -def main(args): - gopath = os.getenv('GOPATH', None) - if not gopath: - print >> sys.stderr, 'GOPATH not set' - return 1 - - try: - imports = imputil.collect_imports(args.modname, args.script, gopath) - except SyntaxError as e: - print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( - e.filename, e.lineno, e.text) - return 2 - except util.CompileError as e: - print >> sys.stderr, str(e) - return 2 - - names = set([args.modname]) - for imp in imports: - if imp.is_native: - print imp.name - else: - parts = imp.name.split('.') - # Iterate over all packages and the leaf module. - for i in xrange(len(parts)): - name = '.'.join(parts[:i+1]) - if name not in names: - names.add(name) - print name - - -if __name__ == '__main__': - main(parser.parse_args()) From a075e295ef28a296b40546492aee56651a2b3798 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 23 Mar 2018 19:44:02 -0300 Subject: [PATCH 24/73] bin/pydeps -> grumpy dependents --- grumpy-runtime-src/tools/pydeps | 64 +------------------------ grumpy-tools-src/grumpy_tools/cli.py | 13 ++++- grumpy-tools-src/grumpy_tools/pydeps.py | 55 +++++++++++++++++++++ 3 files changed, 69 insertions(+), 63 deletions(-) create mode 100755 grumpy-tools-src/grumpy_tools/pydeps.py diff --git a/grumpy-runtime-src/tools/pydeps b/grumpy-runtime-src/tools/pydeps index d72dc9fa..55eb42a2 100755 --- a/grumpy-runtime-src/tools/pydeps +++ b/grumpy-runtime-src/tools/pydeps @@ -1,63 +1,3 @@ -#!/usr/bin/env python +#!/bin/bash -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Outputs names of modules imported by a script.""" - -import argparse -import os -import sys - -from grumpy_tools.compiler import imputil -from grumpy_tools.compiler import util - - -parser = argparse.ArgumentParser() -parser.add_argument('script', help='Python source filename') -parser.add_argument('-modname', default='__main__', help='Python module name') - - -def main(args): - gopath = os.getenv('GOPATH', None) - if not gopath: - print >> sys.stderr, 'GOPATH not set' - return 1 - - try: - imports = imputil.collect_imports(args.modname, args.script, gopath) - except SyntaxError as e: - print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( - e.filename, e.lineno, e.text) - return 2 - except util.CompileError as e: - print >> sys.stderr, str(e) - return 2 - - names = set([args.modname]) - for imp in imports: - if imp.is_native: - print imp.name - else: - parts = imp.name.split('.') - # Iterate over all packages and the leaf module. - for i in xrange(len(parts)): - name = '.'.join(parts[:i+1]) - if name not in names: - names.add(name) - print name - - -if __name__ == '__main__': - main(parser.parse_args()) +exec grumpy depends $@ diff --git a/grumpy-tools-src/grumpy_tools/cli.py b/grumpy-tools-src/grumpy_tools/cli.py index 94b4e46c..474eb224 100644 --- a/grumpy-tools-src/grumpy_tools/cli.py +++ b/grumpy-tools-src/grumpy_tools/cli.py @@ -5,7 +5,7 @@ import click -from . import grumpc, grumprun +from . import grumpc, grumprun, pydeps @click.group('grumpy') @@ -32,6 +32,17 @@ def run(modname=None): sys.exit(result) +@main.command('depends') +@click.argument('script') +@click.option('-m', '-modname', '--modname', default='__main__', help='Python module name') +def depends(script=None, modname=None): + """ + Translates the python SCRIPT file to Go, then prints to stdout + """ + result = pydeps.main(script=script, modname=modname) + sys.exit(result) + + if __name__ == "__main__": import sys sys.exit(main()) diff --git a/grumpy-tools-src/grumpy_tools/pydeps.py b/grumpy-tools-src/grumpy_tools/pydeps.py new file mode 100755 index 00000000..54ed37a8 --- /dev/null +++ b/grumpy-tools-src/grumpy_tools/pydeps.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Outputs names of modules imported by a script.""" +from __future__ import absolute_import + +import os +import sys + +from .compiler import imputil +from .compiler import util + + +def main(script=None, modname=None): + gopath = os.getenv('GOPATH', None) + if not gopath: + print >> sys.stderr, 'GOPATH not set' + return 1 + + try: + imports = imputil.collect_imports(modname, script, gopath) + except SyntaxError as e: + print >> sys.stderr, '{}: line {}: invalid syntax: {}'.format( + e.filename, e.lineno, e.text) + return 2 + except util.CompileError as e: + print >> sys.stderr, str(e) + return 2 + + names = set([modname]) + for imp in imports: + if imp.is_native: + print imp.name + else: + parts = imp.name.split('.') + # Iterate over all packages and the leaf module. + for i in xrange(len(parts)): + name = '.'.join(parts[:i+1]) + if name not in names: + names.add(name) + print name + From 952c5fdde6e96d9dcfbd73985c4deb4c0f1f0c50 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 23 Mar 2018 19:49:31 -0300 Subject: [PATCH 25/73] Remove symlink hack for pydeps --- grumpy-runtime-src/compiler | 1 - 1 file changed, 1 deletion(-) delete mode 120000 grumpy-runtime-src/compiler diff --git a/grumpy-runtime-src/compiler b/grumpy-runtime-src/compiler deleted file mode 120000 index e2993627..00000000 --- a/grumpy-runtime-src/compiler +++ /dev/null @@ -1 +0,0 @@ -../grumpy-tools-src/grumpy_tools/compiler/ \ No newline at end of file From 52a3fe9c0ee68ef029ccc403007c7af0d8850ba2 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 23 Mar 2018 21:01:00 -0300 Subject: [PATCH 26/73] Do not pylint bash scripts --- grumpy-runtime-src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/Makefile b/grumpy-runtime-src/Makefile index c75d2115..5186dcc6 100644 --- a/grumpy-runtime-src/Makefile +++ b/grumpy-runtime-src/Makefile @@ -247,7 +247,7 @@ $(PYLINT_BIN): @cd build/third_party/pylint-1.6.4 && $(PYTHON) setup.py install --prefix $(ROOT_DIR)/build pylint: $(PYLINT_BIN) $(COMPILER_SRCS) $(PYTHONPARSER_SRCS) $(TOOL_BINS) - @$(PYTHON) $(PYLINT_BIN) $(COMPILER_SRCS) $(TOOL_BINS) + @$(PYTHON) $(PYLINT_BIN) $(COMPILER_SRCS) $(filter-out %pydeps,$(TOOL_BINS)) lint: golint pylint From 3527b0b925018066e0d43f0fdac4b7f82ae68af6 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 23 Mar 2018 21:14:33 -0300 Subject: [PATCH 27/73] Fix import --- grumpy-tools-src/tests/test_grumpy_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-tools-src/tests/test_grumpy_tools.py b/grumpy-tools-src/tests/test_grumpy_tools.py index e8f4f333..f9d1d2fb 100644 --- a/grumpy-tools-src/tests/test_grumpy_tools.py +++ b/grumpy-tools-src/tests/test_grumpy_tools.py @@ -7,7 +7,7 @@ from click.testing import CliRunner -from grumpy import cli +from grumpy_tools import cli @pytest.fixture From 5b81c1ba2b01e69165cb8bedacaff2cd3405dab4 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 28 Mar 2018 19:57:59 -0300 Subject: [PATCH 28/73] MakeCommand for building the runtime --- setup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/setup.py b/setup.py index df86ba7e..b91c6bef 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,8 @@ """The setup script.""" from setuptools import setup, find_packages +from distutils.command.build import build as BuildCommand +import subprocess with open('README.md') as readme_file: readme = readme_file.read() @@ -83,12 +85,23 @@ GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) +class MakeCommand(BuildCommand): + def run(self, *args, **kwargs): + result = BuildCommand.run(self, *args, **kwargs) + subprocess.check_call(["cd grumpy-runtime-src && make"], shell=True) + + return result + + GRUMPY_RUNTIME_OPTIONS = dict( package_dir={'':'grumpy-runtime-src'}, packages=find_packages( 'grumpy-runtime-src', exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), + cmdclass={ + 'build': MakeCommand, + }, ) GRUMPY_RUNTIME_OPTIONS.update(COMMON_OPTIONS) From 39accab8f0775d4cd32219cc39b5f3de44821d2d Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 4 Apr 2018 01:03:08 -0300 Subject: [PATCH 29/73] ensure recent setuptools --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b91c6bef..0cce22db 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ ] setup_requirements = [ + 'setuptools>=28.8.0', 'pytest-runner', # TODO(alanjds): Put setup requirements (distutils extensions, etc.) here ] From b83a52528bb0446334c7f76891b774b7099497b5 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 4 Apr 2018 01:04:07 -0300 Subject: [PATCH 30/73] name the two packages properly --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0cce22db..36ae7380 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,6 @@ ] COMMON_OPTIONS = dict( - name='grumpy-tools', version='0.1.0', description="Grumpy Runtime & Transpiler", long_description=readme, @@ -72,6 +71,7 @@ GRUMPY_TOOLS_OPTIONS = dict( + name='grumpy-tools', package_dir={'':'grumpy-tools-src'}, packages=find_packages( 'grumpy-tools-src', @@ -95,6 +95,8 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( + name='grumpy-runtime', + requires=['grumpy_tools'], package_dir={'':'grumpy-runtime-src'}, packages=find_packages( 'grumpy-runtime-src', From fe435022405a719dcf15f13ca704c34146e7bc4c Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 4 Apr 2018 01:04:47 -0300 Subject: [PATCH 31/73] explicitly set the build command for each pack --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 36ae7380..107d6099 100644 --- a/setup.py +++ b/setup.py @@ -82,6 +82,9 @@ 'grumpy=grumpy_tools.cli:main', ], }, + cmdclass={ + 'build': BuildCommand, + }, ) GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) From 917ea5f8573431520f78ebbf74dbdddda8044906 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 6 Apr 2018 13:54:24 -0300 Subject: [PATCH 32/73] Fixed grumpc grumprun and pydeps on setup.py build phase --- grumpy-runtime-src/tools/grumpc | 16 ++++++++++++++-- grumpy-runtime-src/tools/grumprun | 16 ++++++++++++++-- grumpy-runtime-src/tools/pydeps | 15 +++++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/grumpy-runtime-src/tools/grumpc b/grumpy-runtime-src/tools/grumpc index 64c0b7a1..0dc6e650 100755 --- a/grumpy-runtime-src/tools/grumpc +++ b/grumpy-runtime-src/tools/grumpc @@ -1,3 +1,15 @@ -#!/bin/bash +#!/usr/bin/env python +## Import boilerplate +import os +import sys +try: + import grumpy_tools +except ImportError: # Fallback to local folder + sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) +## end. -exec grumpy transpile $@ +import sys +from grumpy_tools import cli + +sys.argv = ['grumpy', 'transpile'] + sys.argv[1:] +sys.exit(cli.main()) diff --git a/grumpy-runtime-src/tools/grumprun b/grumpy-runtime-src/tools/grumprun index b96c2218..5cd7a070 100755 --- a/grumpy-runtime-src/tools/grumprun +++ b/grumpy-runtime-src/tools/grumprun @@ -1,3 +1,15 @@ -#!/bin/bash +#!/usr/bin/env python +## Import boilerplate +import os +import sys +try: + import grumpy_tools +except ImportError: # Fallback to local folder + sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) +## end. -exec grumpy run $@ +import sys +from grumpy_tools import cli + +sys.argv = ['grumpy', 'run'] + sys.argv[1:] +sys.exit(cli.main()) diff --git a/grumpy-runtime-src/tools/pydeps b/grumpy-runtime-src/tools/pydeps index 55eb42a2..1ad9a914 100755 --- a/grumpy-runtime-src/tools/pydeps +++ b/grumpy-runtime-src/tools/pydeps @@ -1,3 +1,14 @@ -#!/bin/bash +#!/usr/bin/env python +## Import boilerplate +import os +import sys +try: + import grumpy_tools +except ImportError: # Fallback to local folder + sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) +## end. -exec grumpy depends $@ +from grumpy_tools import cli + +sys.argv = ['grumpy', 'depends'] + sys.argv[1:] +sys.exit(cli.main()) From ddd300b104c45a644c4d43ff71008b3f6ba51226 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 6 Apr 2018 13:58:04 -0300 Subject: [PATCH 33/73] Show the make --debug logs for now --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 107d6099..c9f85caa 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,7 @@ class MakeCommand(BuildCommand): def run(self, *args, **kwargs): result = BuildCommand.run(self, *args, **kwargs) - subprocess.check_call(["cd grumpy-runtime-src && make"], shell=True) + subprocess.check_call(["cd grumpy-runtime-src && make --debug"], shell=True) return result From 4de7eeca08898687535e345455bc0fe6c51fab3b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 6 Apr 2018 13:58:24 -0300 Subject: [PATCH 34/73] Setup the tools and the runtime --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c9f85caa..2b0697bf 100644 --- a/setup.py +++ b/setup.py @@ -116,4 +116,4 @@ def run(self, *args, **kwargs): setup(**GRUMPY_TOOLS_OPTIONS) # ## Just the "runtime" -# setup(**GRUMPY_RUNTIME_OPTIONS) +setup(**GRUMPY_RUNTIME_OPTIONS) From df3f644b439aba0dd491d1c1912bfe86a08d925e Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 6 Apr 2018 14:29:43 -0300 Subject: [PATCH 35/73] Should build on install too --- setup.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 2b0697bf..8f59a564 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ """The setup script.""" from setuptools import setup, find_packages +from setuptools.command.bdist_egg import bdist_egg as BdistEggCommand from distutils.command.build import build as BuildCommand import subprocess @@ -82,19 +83,24 @@ 'grumpy=grumpy_tools.cli:main', ], }, - cmdclass={ - 'build': BuildCommand, - }, ) GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) -class MakeCommand(BuildCommand): +def _run_make(self, *args, **kwargs): + subprocess.check_call(["cd grumpy-runtime-src && make --debug"], shell=True) + + +class BuildMakeCommand(BuildCommand): def run(self, *args, **kwargs): + _run_make(self, *args, **kwargs) result = BuildCommand.run(self, *args, **kwargs) - subprocess.check_call(["cd grumpy-runtime-src && make --debug"], shell=True) - return result + +class BdistEggMakeCommand(BdistEggCommand): + def run(self, *args, **kwargs): + _run_make(self, *args, **kwargs) + result = BdistEggCommand.run(self, *args, **kwargs) GRUMPY_RUNTIME_OPTIONS = dict( @@ -106,8 +112,10 @@ def run(self, *args, **kwargs): exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), cmdclass={ - 'build': MakeCommand, + 'build': BuildMakeCommand, + 'bdist_egg': BdistEggMakeCommand, }, + zip_safe=False, ) GRUMPY_RUNTIME_OPTIONS.update(COMMON_OPTIONS) From 4446db8180176d820e814eb8cd95f36077ce8dad Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 3 May 2018 09:17:21 -0300 Subject: [PATCH 36/73] More divided options --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8f59a564..38235278 100644 --- a/setup.py +++ b/setup.py @@ -44,14 +44,13 @@ ] COMMON_OPTIONS = dict( - version='0.1.0', + version='0.1.1', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", maintainer="Alan Justino et al.", maintainer_email="alan.justino@yahoo.com.br", url='https://github.com/google/grumpy', - include_package_data=True, install_requires=requirements, license="Apache Software License 2.0", zip_safe=False, @@ -78,6 +77,7 @@ 'grumpy-tools-src', exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), + include_package_data=False, entry_points={ 'console_scripts': [ 'grumpy=grumpy_tools.cli:main', @@ -111,6 +111,7 @@ def run(self, *args, **kwargs): 'grumpy-runtime-src', exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), + include_package_data=True, cmdclass={ 'build': BuildMakeCommand, 'bdist_egg': BdistEggMakeCommand, From 020576e0ded519270831f37355018cb38383838f Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 3 May 2018 09:48:35 -0300 Subject: [PATCH 37/73] Separate setup.py for grumpy-tools --- .gitignore | 12 ++++ setup.py => grumpy-runtime-src/setup.py | 0 grumpy-tools-src/AUTHORS.md | 1 + grumpy-tools-src/CONTRIBUTING.md | 1 + grumpy-tools-src/LICENSE | 1 + grumpy-tools-src/README.md | 1 + grumpy-tools-src/setup.py | 88 +++++++++++++++++++++++++ 7 files changed, 104 insertions(+) rename setup.py => grumpy-runtime-src/setup.py (100%) create mode 120000 grumpy-tools-src/AUTHORS.md create mode 120000 grumpy-tools-src/CONTRIBUTING.md create mode 120000 grumpy-tools-src/LICENSE create mode 120000 grumpy-tools-src/README.md create mode 100644 grumpy-tools-src/setup.py diff --git a/.gitignore b/.gitignore index af4e99f5..dc8c5a8b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,15 @@ build errors.err *.swp *.pyc +*.egg +.eggs/ + +grumpy-tools-src/dist/ +grumpy-tools-src/*.egg-info + +# Cache +.pytest_cache/ + +# Editors +.vscode/ + diff --git a/setup.py b/grumpy-runtime-src/setup.py similarity index 100% rename from setup.py rename to grumpy-runtime-src/setup.py diff --git a/grumpy-tools-src/AUTHORS.md b/grumpy-tools-src/AUTHORS.md new file mode 120000 index 00000000..3234d6e0 --- /dev/null +++ b/grumpy-tools-src/AUTHORS.md @@ -0,0 +1 @@ +../AUTHORS.md \ No newline at end of file diff --git a/grumpy-tools-src/CONTRIBUTING.md b/grumpy-tools-src/CONTRIBUTING.md new file mode 120000 index 00000000..44fcc634 --- /dev/null +++ b/grumpy-tools-src/CONTRIBUTING.md @@ -0,0 +1 @@ +../CONTRIBUTING.md \ No newline at end of file diff --git a/grumpy-tools-src/LICENSE b/grumpy-tools-src/LICENSE new file mode 120000 index 00000000..ea5b6064 --- /dev/null +++ b/grumpy-tools-src/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/grumpy-tools-src/README.md b/grumpy-tools-src/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/grumpy-tools-src/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py new file mode 100644 index 00000000..77dc0a7c --- /dev/null +++ b/grumpy-tools-src/setup.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""The setup script.""" + +import sys +from setuptools import setup, find_packages + +with open('README.md') as readme_file: + readme = readme_file.read() + +requirements = [ + 'Click>=6.0', + # TODO: Put package requirements here + 'importlib2>=3.5.0.2', + 'click-default-group>=1.2', +] + +setup_requirements = [ + # TODO(alanjds): Put setup requirements (distutils extensions, etc.) here +] + +test_requirements = [ + 'pytest', + # TODO: Put package test requirements here +] + +needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) +if needs_pytest: + setup_requirements += ['pytest-runner'] + + +COMMON_OPTIONS = dict( + version='0.1.1', + description="Grumpy Runtime & Transpiler", + long_description=readme, + author="Dylan Trotter et al.", + maintainer="Alan Justino et al.", + maintainer_email="alan.justino@yahoo.com.br", + url='https://github.com/google/grumpy', + install_requires=requirements, + license="Apache Software License 2.0", + zip_safe=False, + keywords='grumpy_runtime', + python_requires='~=2.7.0', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + "Programming Language :: Python :: 2", + 'Programming Language :: Python :: 2.7', + ], + test_suite='tests', + tests_require=test_requirements, + setup_requires=setup_requirements, +) + +GRUMPY_TOOLS_OPTIONS = dict( + name='grumpy-tools', + packages=find_packages( + exclude=["*.tests", "*.tests.*", "tests.*", "tests"], + ), + include_package_data=False, + entry_points={ + 'console_scripts': [ + 'grumpy=grumpy_tools.cli:main', + ], + }, +) + +GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) + +setup(**GRUMPY_TOOLS_OPTIONS) From 84f5755d04d3414f6f26fa1f8b4350f1d23797f1 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 3 May 2018 10:19:08 -0300 Subject: [PATCH 38/73] Most runtime files were added via MANIFEST.in --- .gitignore | 2 ++ grumpy-runtime-src/AUTHORS.md | 1 + grumpy-runtime-src/CONTRIBUTING.md | 1 + grumpy-runtime-src/LICENSE | 1 + grumpy-runtime-src/MANIFEST.in | 11 +++++++++++ grumpy-runtime-src/README.md | 1 + grumpy-runtime-src/setup.py | 29 +++++------------------------ 7 files changed, 22 insertions(+), 24 deletions(-) create mode 120000 grumpy-runtime-src/AUTHORS.md create mode 120000 grumpy-runtime-src/CONTRIBUTING.md create mode 120000 grumpy-runtime-src/LICENSE create mode 100644 grumpy-runtime-src/MANIFEST.in create mode 120000 grumpy-runtime-src/README.md diff --git a/.gitignore b/.gitignore index dc8c5a8b..c9619d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ errors.err grumpy-tools-src/dist/ grumpy-tools-src/*.egg-info +grumpy-runtime-src/dist +grumpy-runtime-src/*.egg-info # Cache .pytest_cache/ diff --git a/grumpy-runtime-src/AUTHORS.md b/grumpy-runtime-src/AUTHORS.md new file mode 120000 index 00000000..3234d6e0 --- /dev/null +++ b/grumpy-runtime-src/AUTHORS.md @@ -0,0 +1 @@ +../AUTHORS.md \ No newline at end of file diff --git a/grumpy-runtime-src/CONTRIBUTING.md b/grumpy-runtime-src/CONTRIBUTING.md new file mode 120000 index 00000000..44fcc634 --- /dev/null +++ b/grumpy-runtime-src/CONTRIBUTING.md @@ -0,0 +1 @@ +../CONTRIBUTING.md \ No newline at end of file diff --git a/grumpy-runtime-src/LICENSE b/grumpy-runtime-src/LICENSE new file mode 120000 index 00000000..ea5b6064 --- /dev/null +++ b/grumpy-runtime-src/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/grumpy-runtime-src/MANIFEST.in b/grumpy-runtime-src/MANIFEST.in new file mode 100644 index 00000000..02c64011 --- /dev/null +++ b/grumpy-runtime-src/MANIFEST.in @@ -0,0 +1,11 @@ +global-include *.py +global-include *.go +global-include *.mk +global-include Makefile + +global-exclude *.egg-info/* +global-exclude *_test.py + +recursive-exclude grumpy-tools-src *.go +prune testing/ +prune third_party/stdlib/test/ \ No newline at end of file diff --git a/grumpy-runtime-src/README.md b/grumpy-runtime-src/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/grumpy-runtime-src/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 38235278..c672848f 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -17,6 +17,7 @@ """The setup script.""" +import sys from setuptools import setup, find_packages from setuptools.command.bdist_egg import bdist_egg as BdistEggCommand from distutils.command.build import build as BuildCommand @@ -43,6 +44,10 @@ # TODO: Put package test requirements here ] +needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) +if needs_pytest: + setup_requirements += ['pytest-runner'] + COMMON_OPTIONS = dict( version='0.1.1', description="Grumpy Runtime & Transpiler", @@ -70,23 +75,6 @@ ) -GRUMPY_TOOLS_OPTIONS = dict( - name='grumpy-tools', - package_dir={'':'grumpy-tools-src'}, - packages=find_packages( - 'grumpy-tools-src', - exclude=["*.tests", "*.tests.*", "tests.*", "tests"], - ), - include_package_data=False, - entry_points={ - 'console_scripts': [ - 'grumpy=grumpy_tools.cli:main', - ], - }, -) -GRUMPY_TOOLS_OPTIONS.update(COMMON_OPTIONS) - - def _run_make(self, *args, **kwargs): subprocess.check_call(["cd grumpy-runtime-src && make --debug"], shell=True) @@ -106,9 +94,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', requires=['grumpy_tools'], - package_dir={'':'grumpy-runtime-src'}, packages=find_packages( - 'grumpy-runtime-src', exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), include_package_data=True, @@ -120,9 +106,4 @@ def run(self, *args, **kwargs): ) GRUMPY_RUNTIME_OPTIONS.update(COMMON_OPTIONS) - -## Just the "tools" -setup(**GRUMPY_TOOLS_OPTIONS) - -# ## Just the "runtime" setup(**GRUMPY_RUNTIME_OPTIONS) From 4cce2551315b289f769dda3741c139044fd05851 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 3 May 2018 10:37:07 -0300 Subject: [PATCH 39/73] A better make command --- grumpy-runtime-src/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index c672848f..9088e6aa 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -76,7 +76,7 @@ def _run_make(self, *args, **kwargs): - subprocess.check_call(["cd grumpy-runtime-src && make --debug"], shell=True) + subprocess.check_call(["""echo "print 'Make Runtime Success'" | make run --debug"""], shell=True) class BuildMakeCommand(BuildCommand): From d7b2b8be46272c66e655f63baa0cc90f2fc62f94 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 5 May 2018 18:07:20 -0300 Subject: [PATCH 40/73] Should include tools! --- grumpy-runtime-src/MANIFEST.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grumpy-runtime-src/MANIFEST.in b/grumpy-runtime-src/MANIFEST.in index 02c64011..8ff868f2 100644 --- a/grumpy-runtime-src/MANIFEST.in +++ b/grumpy-runtime-src/MANIFEST.in @@ -2,10 +2,11 @@ global-include *.py global-include *.go global-include *.mk global-include Makefile +recursive-include tools * global-exclude *.egg-info/* global-exclude *_test.py recursive-exclude grumpy-tools-src *.go prune testing/ -prune third_party/stdlib/test/ \ No newline at end of file +prune third_party/stdlib/test/ From c9c5a85334506458bf3f8c165ee48176a158a27b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 12 May 2018 16:49:51 -0300 Subject: [PATCH 41/73] You need tests shipped to be able to compile _for now_ --- grumpy-runtime-src/MANIFEST.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/grumpy-runtime-src/MANIFEST.in b/grumpy-runtime-src/MANIFEST.in index 8ff868f2..7f60bcbd 100644 --- a/grumpy-runtime-src/MANIFEST.in +++ b/grumpy-runtime-src/MANIFEST.in @@ -5,8 +5,5 @@ global-include Makefile recursive-include tools * global-exclude *.egg-info/* -global-exclude *_test.py recursive-exclude grumpy-tools-src *.go -prune testing/ -prune third_party/stdlib/test/ From aefa49f26f5f4ac09442eb52edf45dc4e6e5b3d4 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 12 May 2018 17:01:21 -0300 Subject: [PATCH 42/73] Shoud have installed grumpy-tools before. For now. --- grumpy-runtime-src/tools/grumpc | 7 ------- grumpy-runtime-src/tools/grumprun | 7 ------- grumpy-runtime-src/tools/pydeps | 6 ------ 3 files changed, 20 deletions(-) diff --git a/grumpy-runtime-src/tools/grumpc b/grumpy-runtime-src/tools/grumpc index 0dc6e650..a9974b12 100755 --- a/grumpy-runtime-src/tools/grumpc +++ b/grumpy-runtime-src/tools/grumpc @@ -1,13 +1,6 @@ #!/usr/bin/env python ## Import boilerplate import os -import sys -try: - import grumpy_tools -except ImportError: # Fallback to local folder - sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) -## end. - import sys from grumpy_tools import cli diff --git a/grumpy-runtime-src/tools/grumprun b/grumpy-runtime-src/tools/grumprun index 5cd7a070..788e8891 100755 --- a/grumpy-runtime-src/tools/grumprun +++ b/grumpy-runtime-src/tools/grumprun @@ -1,13 +1,6 @@ #!/usr/bin/env python ## Import boilerplate import os -import sys -try: - import grumpy_tools -except ImportError: # Fallback to local folder - sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) -## end. - import sys from grumpy_tools import cli diff --git a/grumpy-runtime-src/tools/pydeps b/grumpy-runtime-src/tools/pydeps index 1ad9a914..ad95f5a8 100755 --- a/grumpy-runtime-src/tools/pydeps +++ b/grumpy-runtime-src/tools/pydeps @@ -1,12 +1,6 @@ #!/usr/bin/env python -## Import boilerplate import os import sys -try: - import grumpy_tools -except ImportError: # Fallback to local folder - sys.path.append(os.path.join(os.getcwd(), '../grumpy-tools-src/')) -## end. from grumpy_tools import cli From 2271dde6ddfdc4af1203a71f153ad259540b4d96 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sun, 13 May 2018 13:55:54 -0300 Subject: [PATCH 43/73] New __init__ to have something installed --- grumpy-runtime-src/grumpy_runtime/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 grumpy-runtime-src/grumpy_runtime/__init__.py diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py new file mode 100644 index 00000000..be43451e --- /dev/null +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = '(unknown)' From 37daf670c36c91793a3a3c83e1c1067e3c693f41 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sun, 13 May 2018 23:27:19 -0300 Subject: [PATCH 44/73] Working `pip install grumpy-runtime` with data The "data" is built on build_py step, and moved into the package data folder --- grumpy-runtime-src/setup.py | 46 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 9088e6aa..0f159e61 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -17,10 +17,12 @@ """The setup script.""" +import os +import fnmatch +import shutil import sys from setuptools import setup, find_packages -from setuptools.command.bdist_egg import bdist_egg as BdistEggCommand -from distutils.command.build import build as BuildCommand +from distutils.command.build_py import build_py as BuildCommand import subprocess with open('README.md') as readme_file: @@ -79,16 +81,43 @@ def _run_make(self, *args, **kwargs): subprocess.check_call(["""echo "print 'Make Runtime Success'" | make run --debug"""], shell=True) +def _glob_deep(directory, pattern): + # From: https://stackoverflow.com/a/2186673/798575 + for root, dirs, files in os.walk(directory): + for basename in files: + if fnmatch.fnmatch(basename, pattern): + filename = os.path.join(root, basename) + yield filename + + class BuildMakeCommand(BuildCommand): def run(self, *args, **kwargs): + # Thanks http://www.digip.org/blog/2011/01/generating-data-files-in-setup.py.html for the tip + _run_make(self, *args, **kwargs) - result = BuildCommand.run(self, *args, **kwargs) + # Makefile creates a "gopath" folder named "build" on root folder. Change it! + shutil.move('build', 'gopath') -class BdistEggMakeCommand(BdistEggCommand): - def run(self, *args, **kwargs): - _run_make(self, *args, **kwargs) - result = BdistEggCommand.run(self, *args, **kwargs) + if not self.dry_run: + target_dir = os.path.join(self.build_lib, 'grumpy_runtime/data') + self.mkpath(target_dir) + shutil.move('gopath', target_dir) + + build_dir = os.path.join(self.build_lib, 'grumpy_runtime') + built_files = _glob_deep(os.path.join(build_dir, 'gopath'), '*') + + # Strip directory from globbed filenames + build_dir_len = len(build_dir) + 1 # One more for leading "/" + built_files = [fn[build_dir_len:] for fn in built_files] + + self.data_files = [ + # (package, src_dir, build_dir, filenames[]) + ('grumpy_runtime', 'grumpy_runtime', build_dir, built_files), + ] + + super_result = BuildCommand.run(self, *args, **kwargs) + return super_result GRUMPY_RUNTIME_OPTIONS = dict( @@ -99,8 +128,7 @@ def run(self, *args, **kwargs): ), include_package_data=True, cmdclass={ - 'build': BuildMakeCommand, - 'bdist_egg': BdistEggMakeCommand, + 'build_py': BuildMakeCommand, }, zip_safe=False, ) From fec293c353b4f4170b680f854248d127d789e70a Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 7 Mar 2018 19:00:29 -0300 Subject: [PATCH 45/73] Fix overflow on math.MaxInt64 --- grumpy-runtime-src/tools/pkgc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grumpy-runtime-src/tools/pkgc.go b/grumpy-runtime-src/tools/pkgc.go index 4b08aac5..e04017c7 100644 --- a/grumpy-runtime-src/tools/pkgc.go +++ b/grumpy-runtime-src/tools/pkgc.go @@ -65,7 +65,11 @@ func getConst(name string, v constant.Value) string { case constant.Int: if constant.Sign(v) >= 0 { if i, exact := constant.Uint64Val(v); exact { - if i > math.MaxInt64 { + if i < math.MaxInt8 { + format = "uint(%s)" + } else if i < math.MaxInt32 { + format = "uint32(%s)" + } else { format = "uint64(%s)" } } else { From 48dad22bab6269f263b14663511fca912a4d0572 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 7 Mar 2018 19:30:45 -0300 Subject: [PATCH 46/73] Fix int underflow on 32bit CPUs --- grumpy-runtime-src/tools/pkgc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grumpy-runtime-src/tools/pkgc.go b/grumpy-runtime-src/tools/pkgc.go index e04017c7..93a6fe7d 100644 --- a/grumpy-runtime-src/tools/pkgc.go +++ b/grumpy-runtime-src/tools/pkgc.go @@ -75,6 +75,16 @@ func getConst(name string, v constant.Value) string { } else { format = "float64(%s)" } + } else { + if i, exact := constant.Int64Val(v); exact { + if i > math.MinInt8 { + format = "int(%s)" + } else if i > math.MinInt32 { + format = "int32(%s)" + } else { + format = "int64(%s)" + } + } } case constant.Float: format = "float64(%s)" From 25a1b60ca9b41b6ec3b4b1139a90196e3cf33fd5 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 18:15:52 -0300 Subject: [PATCH 47/73] Abort `grumpy run` command if grumpy-runtime is not available --- grumpy-tools-src/grumpy_tools/cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grumpy-tools-src/grumpy_tools/cli.py b/grumpy-tools-src/grumpy_tools/cli.py index 474eb224..f32e72fd 100644 --- a/grumpy-tools-src/grumpy_tools/cli.py +++ b/grumpy-tools-src/grumpy_tools/cli.py @@ -2,6 +2,7 @@ """Console script for grumpy_tools.""" import sys +from pkg_resources import resource_filename, Requirement, DistributionNotFound import click @@ -28,6 +29,17 @@ def transpile(script=None, modname=None): @main.command('run') @click.option('-m', '-modname', '--modname', help='Run the named module') def run(modname=None): + try: + runtime_gopath = resource_filename( + Requirement.parse('grumpy-runtime'), + 'grumpy_runtime/data/gopath', + ) + except DistributionNotFound: + runtime_gopath = None + + if not runtime_gopath: + raise click.ClickException("Could not found the Grumpy Runtime 'data/gopath' resource.\n" + "Is 'grumpy-runtime' package installed?") result = grumprun.main(modname=modname) sys.exit(result) From 4fda5cc513a61df33dd002fca114708aff21dcc9 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:08:59 -0300 Subject: [PATCH 48/73] Get the runtime folder from Distribution if not available on GOPATH --- grumpy-tools-src/grumpy_tools/cli.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grumpy-tools-src/grumpy_tools/cli.py b/grumpy-tools-src/grumpy_tools/cli.py index f32e72fd..660ff2b4 100644 --- a/grumpy-tools-src/grumpy_tools/cli.py +++ b/grumpy-tools-src/grumpy_tools/cli.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Console script for grumpy_tools.""" +import os import sys from pkg_resources import resource_filename, Requirement, DistributionNotFound @@ -29,6 +30,8 @@ def transpile(script=None, modname=None): @main.command('run') @click.option('-m', '-modname', '--modname', help='Run the named module') def run(modname=None): + environ_gopath = os.environ.get('GOPATH', '') + try: runtime_gopath = resource_filename( Requirement.parse('grumpy-runtime'), @@ -37,9 +40,16 @@ def run(modname=None): except DistributionNotFound: runtime_gopath = None - if not runtime_gopath: + if runtime_gopath and runtime_gopath not in environ_gopath: + gopaths = environ_gopath.split(':') + [runtime_gopath] + new_gopath = ':'.join([p for p in gopaths if p]) # Filter empty ones + if new_gopath: + os.environ['GOPATH'] = new_gopath + + if not runtime_gopath and not environ_gopath: raise click.ClickException("Could not found the Grumpy Runtime 'data/gopath' resource.\n" "Is 'grumpy-runtime' package installed?") + result = grumprun.main(modname=modname) sys.exit(result) From 8206061226831e72e9ad81c48fc13e67a64beb02 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:11:56 -0300 Subject: [PATCH 49/73] Bump version: 0.1.4 --- grumpy-runtime-src/setup.py | 2 +- grumpy-tools-src/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 0f159e61..885d8881 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -51,7 +51,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.1', + version='0.1.4', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py index 77dc0a7c..83ea6421 100644 --- a/grumpy-tools-src/setup.py +++ b/grumpy-tools-src/setup.py @@ -45,7 +45,7 @@ COMMON_OPTIONS = dict( - version='0.1.1', + version='0.1.4', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From e974db6179e8c21aa0010fc103f4846ec46fbb33 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:15:58 -0300 Subject: [PATCH 50/73] Cleaner setup.py of Runtime --- grumpy-runtime-src/setup.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 885d8881..a4db1b86 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -28,17 +28,8 @@ with open('README.md') as readme_file: readme = readme_file.read() -requirements = [ - 'Click>=6.0', - # TODO: Put package requirements here - 'importlib2>=3.5.0.2', - 'click-default-group>=1.2', -] - setup_requirements = [ 'setuptools>=28.8.0', - 'pytest-runner', - # TODO(alanjds): Put setup requirements (distutils extensions, etc.) here ] test_requirements = [ From ade1aee55658a056a65d17e113b372f1ea2f3f72 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:16:15 -0300 Subject: [PATCH 51/73] Runtime needs Tools >= 0.1.4 --- grumpy-runtime-src/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index a4db1b86..e0ecdefe 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -113,7 +113,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', - requires=['grumpy_tools'], + requires=['grumpy_tools>=0.1.4'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), From 5512840b4a216041cadda6acbd4c5a068372e865 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:18:46 -0300 Subject: [PATCH 52/73] Update install_requires --- grumpy-runtime-src/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index e0ecdefe..cc67ddbe 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -49,7 +49,6 @@ maintainer="Alan Justino et al.", maintainer_email="alan.justino@yahoo.com.br", url='https://github.com/google/grumpy', - install_requires=requirements, license="Apache Software License 2.0", zip_safe=False, keywords='grumpy_runtime', @@ -114,6 +113,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', requires=['grumpy_tools>=0.1.4'], + install_requires=['grumpy_tools>=0.1.4'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), From 8b9e6214e18193c41892bc30f5b06666e38485ae Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 19:40:20 -0300 Subject: [PATCH 53/73] Bump version: 0.1.5 --- grumpy-runtime-src/setup.py | 13 ++++++++----- grumpy-tools-src/setup.py | 9 ++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index cc67ddbe..c7e86a39 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -25,8 +25,11 @@ from distutils.command.build_py import build_py as BuildCommand import subprocess -with open('README.md') as readme_file: - readme = readme_file.read() +try: + with open('README.md') as readme_file: + readme = readme_file.read() +except: + readme = '' setup_requirements = [ 'setuptools>=28.8.0', @@ -42,7 +45,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.4', + version='0.1.5', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", @@ -112,8 +115,8 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', - requires=['grumpy_tools>=0.1.4'], - install_requires=['grumpy_tools>=0.1.4'], + requires=['grumpy_tools'], + install_requires=['grumpy-tools>=0.1.5'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py index 83ea6421..66dced0a 100644 --- a/grumpy-tools-src/setup.py +++ b/grumpy-tools-src/setup.py @@ -20,8 +20,11 @@ import sys from setuptools import setup, find_packages -with open('README.md') as readme_file: - readme = readme_file.read() +try: + with open('README.md') as readme_file: + readme = readme_file.read() +except: + readme = '' requirements = [ 'Click>=6.0', @@ -45,7 +48,7 @@ COMMON_OPTIONS = dict( - version='0.1.4', + version='0.1.5', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From a0965def5b4c5a36ad3e91c6bd77be088fb95821 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 20:46:31 -0300 Subject: [PATCH 54/73] Bump to 0.1.5.1: Fix math.go issues on 32bit machines --- grumpy-runtime-src/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index c7e86a39..27b5ed0e 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -45,7 +45,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.5', + version='0.1.5.1', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From f4ec9682b9308a0d690356a458a665efa2aadb09 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 16 May 2018 20:53:49 -0300 Subject: [PATCH 55/73] Inform Travis that paths changed. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ec56655..69968eeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,11 @@ before_script: # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. script: + - cd grumpy-tools-src - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi - which grumpy - - cd grumpy-runtime-src + - cd ../grumpy-runtime-src - make gofmt lint && make -j2 test # OSX swallows error logs: https://github.com/travis-ci/travis-ci/issues/6018 From 89001f0c53909b0c4a8ab49451462abd06bcb4a7 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 17 May 2018 11:25:58 -0300 Subject: [PATCH 56/73] Run Tools tests via `pytest` --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 69968eeb..6a3fdf44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ before_script: - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # https://github.com/travis-ci/travis-ci/issues/8920#issuecomment-352661024 # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install pytest ; fi + - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install pytest --user ; fi script: - cd grumpy-tools-src + - pytest - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi - which grumpy From a4f784ce2db8463aa0eab5921591e4805f05b8cb Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 17 May 2018 11:26:24 -0300 Subject: [PATCH 57/73] Runtime makefile does not need to test Tools compiler (translator). --- grumpy-runtime-src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/Makefile b/grumpy-runtime-src/Makefile index 5186dcc6..394e4bd7 100644 --- a/grumpy-runtime-src/Makefile +++ b/grumpy-runtime-src/Makefile @@ -146,7 +146,7 @@ clean: run: $(RUNNER) @$(RUNNER_BIN) -test: $(ACCEPT_PASS_FILES) $(ACCEPT_PY_PASS_FILES) $(COMPILER_PASS_FILES) $(COMPILER_EXPR_VISITOR_PASS_FILES) $(COMPILER_STMT_PASS_FILES) $(RUNTIME_PASS_FILE) $(STDLIB_PASS_FILES) +test: $(ACCEPT_PASS_FILES) $(ACCEPT_PY_PASS_FILES) $(RUNTIME_PASS_FILE) $(STDLIB_PASS_FILES) precommit: cover gofmt lint test From 70d604bde25db527ca6347106518fe23334c5321 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Thu, 17 May 2018 11:42:16 -0300 Subject: [PATCH 58/73] Run the Tools tests only after the depends got settled --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6a3fdf44..4d3077a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,10 @@ before_script: - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install pytest --user ; fi script: - cd grumpy-tools-src - - pytest - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi - which grumpy + - pytest - cd ../grumpy-runtime-src - make gofmt lint && make -j2 test From 0ac49b20b5d512bd6a6ca642447b369e8d01048d Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 18 May 2018 10:47:27 -0300 Subject: [PATCH 59/73] Fix the Tools tests for Travis --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 69968eeb..6b37d910 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,18 @@ before_script: # Run gofmt and lint serially to avoid confusing output. Run tests in parallel # for speed. script: + # Install the thing - cd grumpy-tools-src - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi - which grumpy - cd ../grumpy-runtime-src + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi + - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi + # Test the thing + - cd ../grumpy-tools-src + - pytest + - cd ../grumpy-runtime-src - make gofmt lint && make -j2 test # OSX swallows error logs: https://github.com/travis-ci/travis-ci/issues/6018 From c8506f16a98e4bbb6a6b38bf4752d6cbfd481dd0 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 18 May 2018 10:50:38 -0300 Subject: [PATCH 60/73] Postpone the Tools tests up to Runtime got installed --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dae2cba1..a9ab044a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi - which grumpy - - pytest - cd ../grumpy-runtime-src - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install . ; fi - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pip2 install . --user ; fi From 1f4073b517234d34498232d5e31b5fb08532daa6 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 18 May 2018 13:48:58 -0300 Subject: [PATCH 61/73] Pin the golang version --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a9ab044a..e71bb99e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: go +go: + - "1.9.2" + - "1.10.x" + os: - linux - osx From e29c1630bd8de29bccb6c59c6d2cee7d80b0c345 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Fri, 18 May 2018 14:22:57 -0300 Subject: [PATCH 62/73] Minimum version on OSX in 1.10. Linux minimum is 1.9, but will not be tested for it for now on. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e71bb99e..4c0be2e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: go go: - - "1.9.2" - "1.10.x" os: From f47b15f746c49620a15062909a20e6bde172bd85 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:21:25 -0300 Subject: [PATCH 63/73] README over the binary distribution usage --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4f690fe4..0258f6b9 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,20 @@ There are three basic categories of incomplete functionality: ### Pre-requisites -The Grumpy Transpiler and Runner tools are provided as a Python Package. -All of the commands below are assumed to be run from the -root directory of the Grumpy source code distribution. Install the package: +The commands ahead assumes that you have Golang installed and a recent +version of Python 2, `setuptools` and `pip`. + +### Method 1: binary package + +For convenience, a Python package is provided from the PyPI. During install, +many Grumpy will be compiled and stored inside your Python installation. + +You need Golang preinstalled anyway for the installation to be successful. ``` -pip2 install -U pip setuptools -python2 setup.py develop +pip2 install -U grumpy-runtime -I --no-cache +(wait about 5 minutes) +echo "print 'hello, world'" | grumpy run ``` ### Method 1: make run: From a65fe78c7075fd11ecffdfea3ef95f46a6edfdae Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:21:53 -0300 Subject: [PATCH 64/73] README Path changes updates --- README.md | 61 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0258f6b9..f2d188fa 100644 --- a/README.md +++ b/README.md @@ -78,11 +78,12 @@ echo "print 'hello, world'" | grumpy run The simplest way to execute a Grumpy program is to use `make run`, which wraps a shell script called grumprun that takes Python code on stdin and builds and runs -the code under Grumpy. All of the commands below are assumed to be run from the -root directory of the Grumpy source code distribution: +the code under Grumpy: ``` -cd grumpy-runtime-src +cd grumpy-tools-src +python2 setup.py develop +cd ../grumpy-runtime-src echo "print 'hello, world'" | make run ``` @@ -100,7 +101,9 @@ The first step is to set up the shell so that the Grumpy toolchain and libraries can be found. From the root directory of the Grumpy source distribution run: ``` -cd grumpy-runtime-src +cd grumpy-tools-src +python2 setup.py develop +cd ../grumpy-runtime-src make export PATH=$PWD/build/bin:$PATH export GOPATH=$PWD/build @@ -153,48 +156,50 @@ grumprun is doing a few things under the hood here: There are three main components and depending on what kind of feature you're writing, you may need to change one or more of these. -### grumpc +### Grumpy Tools -Grumpy converts Python programs into Go programs and `grumpc` is the tool -responsible for parsing Python code and generating Go code from it. `grumpc` is -written in Python and uses the [`pythonparser`](https://github.com/m-labs/pythonparser) +Grumpy converts Python programs into Go programs and +`grumpy transpile` is the CLI tool responsible for parsing Python code +and generating Go code from it. `grumpy transpile` is written in Python +and uses the [`pythonparser`](https://github.com/m-labs/pythonparser) module to accomplish parsing. -The grumpc script itself lives at `tools/grumpc`. It is supported by a number of -Python modules in the `compiler` subdir. +The CLI main entrypoint lives at `grumpy-tools-src/grumpy_tools/cli.py`. +It is supported by a number of Python modules in the +`grumpy-tools-src/grumpy_tools/compiler` subdir. ### Grumpy Runtime -The Go code generated by `grumpc` performs operations on data structures that -represent Python objects in running Grumpy programs. These data structures and -operations are defined in the `grumpy` Go library (source is in the runtime -subdir of the source distribution). This runtime is analogous to the Python C -API and many of the structures and operations defined by `grumpy` have -counterparts in CPython. +The Go code generated by `grumpy transpile` performs operations +on data structures that represent Python objects in running Grumpy programs. +These data structures and operations are defined in the `grumpy` Go library +(source is in the `grumpy-runtime-src/runtime` subdir of the source +distribution). This runtime is analogous to the Python C API and many of the +structures and operations defined by `grumpy` have counterparts in CPython. ### Grumpy Standard Library Much of the Python standard library is written in Python and thus "just works" in Grumpy. These parts of the standard library are copied from CPython 2.7 (possibly with light modifications). For licensing reasons, these files are kept -in the `third_party` subdir. +in the `grumpy-runtime-src/third_party` subdir. The parts of the standard library that cannot be written in pure Python, e.g. -file and directory operations, are kept in the `lib` subdir. In CPython these -kinds of modules are written as C extensions. In Grumpy they are written in -Python but they use native Go extensions to access facilities not otherwise -available in Python. +file and directory operations, are kept in the `grumpy-runtime-src/lib` subdir. +In CPython these kinds of modules are written as C extensions. In Grumpy they +are written in Python but they use native Go extensions to access facilities not +otherwise available in Python. ### Source Code Overview -- `compiler`: Python package implementating Python -> Go transcompilation logic. -- `lib`: Grumpy-specific Python standard library implementation. -- `runtime`: Go source code for the Grumpy runtime library. -- `third_party/ouroboros`: Pure Python standard libraries copied from the +- `grumpy-tools-src/grumpy_tools/compiler`: Python package implementating Python -> Go transcompilation logic. +- `grumpy-runtime-src/lib`: Grumpy-specific Python standard library implementation. +- `grumpy-runtime-src/runtime`: Go source code for the Grumpy runtime library. +- `grumpy-runtime-src/third_party/ouroboros`: Pure Python standard libraries copied from the [Ouroboros project](https://github.com/pybee/ouroboros). -- `third_party/pypy`: Pure Python standard libraries copied from PyPy. -- `third_party/stdlib`: Pure Python standard libraries copied from CPython. -- `tools`: Transcompilation and utility binaries. +- `grumpy-runtime-src/third_party/pypy`: Pure Python standard libraries copied from PyPy. +- `grumpy-runtime-src/third_party/stdlib`: Pure Python standard libraries copied from CPython. +- `grumpy-tools-src/grumpy_tools/`: Transcompilation and utility CLI. ## Contact From 6643980bf1fb9f6d65a21d97a4cc7f45521e4364 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:37:12 -0300 Subject: [PATCH 65/73] Update versions to start using `bumpversion` --- .bumpversion.cfg | 10 ++++++++++ grumpy-runtime-src/grumpy_runtime/__init__.py | 2 +- grumpy-tools-src/grumpy_tools/__init__.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 00000000..13b6a173 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,10 @@ +[bumpversion] +current_version = 0.1.5.1 +commit = True +tag = True + +[bumpversion:file:grumpy-tools-src/setup.py] +[bumpversion:file:grumpy-tools-src/grumpy_tools/__init__.py] + +[bumpversion:file:grumpy-runtime-src/setup.py] +[bumpversion:file:grumpy-runtime-src/grumpy_runtime/__init__.py] diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py index be43451e..2cf307ab 100644 --- a/grumpy-runtime-src/grumpy_runtime/__init__.py +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '(unknown)' +__version__ = '0.1.5.1' diff --git a/grumpy-tools-src/grumpy_tools/__init__.py b/grumpy-tools-src/grumpy_tools/__init__.py index ed7f12d5..ec86f4c6 100644 --- a/grumpy-tools-src/grumpy_tools/__init__.py +++ b/grumpy-tools-src/grumpy_tools/__init__.py @@ -4,4 +4,4 @@ __author__ = """Alan Justino et al.""" __email__ = 'alan.justino@yahoo.com.br' -__version__ = '0.1.0' +__version__ = '0.1.5' From f65b81904f162b61b90e84a93c2e00710fc8b3b9 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:45:23 -0300 Subject: [PATCH 66/73] For now on: major.minor.patch --- .bumpversion.cfg | 2 +- grumpy-runtime-src/grumpy_runtime/__init__.py | 2 +- grumpy-runtime-src/setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 13b6a173..1969f603 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.5.1 +current_version = 0.1.5 commit = True tag = True diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py index 2cf307ab..0b971025 100644 --- a/grumpy-runtime-src/grumpy_runtime/__init__.py +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '0.1.5.1' +__version__ = '0.1.5' diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 27b5ed0e..c7e86a39 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -45,7 +45,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.5.1', + version='0.1.5', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From 88caf6c91b8a8f2b9f6cf657c7869f1b7fde9569 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:46:04 -0300 Subject: [PATCH 67/73] =?UTF-8?q?Bump=20version:=200.1.5=20=E2=86=92=200.1?= =?UTF-8?q?.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 5 ++++- grumpy-runtime-src/grumpy_runtime/__init__.py | 2 +- grumpy-runtime-src/setup.py | 4 ++-- grumpy-tools-src/grumpy_tools/__init__.py | 2 +- grumpy-tools-src/setup.py | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 1969f603..5e652169 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,10 +1,13 @@ [bumpversion] -current_version = 0.1.5 +current_version = 0.1.6 commit = True tag = True [bumpversion:file:grumpy-tools-src/setup.py] + [bumpversion:file:grumpy-tools-src/grumpy_tools/__init__.py] [bumpversion:file:grumpy-runtime-src/setup.py] + [bumpversion:file:grumpy-runtime-src/grumpy_runtime/__init__.py] + diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py index 0b971025..257520d6 100644 --- a/grumpy-runtime-src/grumpy_runtime/__init__.py +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '0.1.5' +__version__ = '0.1.6' diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index c7e86a39..0beec2bc 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -45,7 +45,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.5', + version='0.1.6', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", @@ -116,7 +116,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', requires=['grumpy_tools'], - install_requires=['grumpy-tools>=0.1.5'], + install_requires=['grumpy-tools>=0.1.6'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), diff --git a/grumpy-tools-src/grumpy_tools/__init__.py b/grumpy-tools-src/grumpy_tools/__init__.py index ec86f4c6..1d3b22e3 100644 --- a/grumpy-tools-src/grumpy_tools/__init__.py +++ b/grumpy-tools-src/grumpy_tools/__init__.py @@ -4,4 +4,4 @@ __author__ = """Alan Justino et al.""" __email__ = 'alan.justino@yahoo.com.br' -__version__ = '0.1.5' +__version__ = '0.1.6' diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py index 66dced0a..c211259e 100644 --- a/grumpy-tools-src/setup.py +++ b/grumpy-tools-src/setup.py @@ -48,7 +48,7 @@ COMMON_OPTIONS = dict( - version='0.1.5', + version='0.1.6', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From 983735d1a61d531e758253d7d596b1066262d983 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Mon, 21 May 2018 18:53:49 -0300 Subject: [PATCH 68/73] Badge and link to the forked alanjds/grumpy repo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2d188fa..ea2f0d94 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Grumpy: Go running Python -[![Build Status](https://travis-ci.org/google/grumpy.svg?branch=master)](https://travis-ci.org/google/grumpy) +[![Build Status](https://travis-ci.org/alanjds/grumpy.svg?branch=master)](https://travis-ci.org/alanjds/grumpy) [![Join the chat at https://gitter.im/grumpy-devel/Lobby](https://badges.gitter.im/grumpy-devel/Lobby.svg)](https://gitter.im/grumpy-devel/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Overview From 8b8a1b8d4c2660a93f590800a42473d7fce8d2b7 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 22 May 2018 19:04:12 -0300 Subject: [PATCH 69/73] Different build commands for install and develop Develop uses a symlink. --- grumpy-runtime-src/grumpy_runtime/data/gopath | 1 + grumpy-runtime-src/setup.py | 43 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 120000 grumpy-runtime-src/grumpy_runtime/data/gopath diff --git a/grumpy-runtime-src/grumpy_runtime/data/gopath b/grumpy-runtime-src/grumpy_runtime/data/gopath new file mode 120000 index 00000000..d77d3f3c --- /dev/null +++ b/grumpy-runtime-src/grumpy_runtime/data/gopath @@ -0,0 +1 @@ +../../build/lib/grumpy_runtime/data/gopath \ No newline at end of file diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 0beec2bc..ca04bcfc 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -22,7 +22,8 @@ import shutil import sys from setuptools import setup, find_packages -from distutils.command.build_py import build_py as BuildCommand +from distutils.command.build_py import build_py as BuildPyCommand +from distutils.command.build_ext import build_ext as BuildExtCommand import subprocess try: @@ -83,7 +84,40 @@ def _glob_deep(directory, pattern): yield filename -class BuildMakeCommand(BuildCommand): +class BuildMakeCommandInstall(BuildPyCommand): # Ran on setup.py install + def run(self, *args, **kwargs): + # Thanks http://www.digip.org/blog/2011/01/generating-data-files-in-setup.py.html for the tip + + _run_make(self, *args, **kwargs) + + # Makefile creates a "gopath" folder named "build" on root folder. Change it! + shutil.move('build', 'gopath') + + if not self.dry_run: + target_dir = os.path.join(self.build_lib, 'grumpy_runtime/data') + + # Remove the symlink used on develop + shutil.rmtree(target_dir) + self.mkpath(target_dir) + shutil.move('gopath', target_dir) + + build_dir = os.path.join(self.build_lib, 'grumpy_runtime') + built_files = _glob_deep(os.path.join(build_dir, 'gopath'), '*') + + # Strip directory from globbed filenames + build_dir_len = len(build_dir) + 1 # One more for leading "/" + built_files = [fn[build_dir_len:] for fn in built_files] + + self.data_files = [ + # (package, src_dir, build_dir, filenames[]) + ('grumpy_runtime', 'grumpy_runtime', build_dir, built_files), + ] + + super_result = BuildPyCommand.run(self, *args, **kwargs) + return super_result + + +class BuildMakeCommandDevelop(BuildExtCommand): # Ran on setup.py develop def run(self, *args, **kwargs): # Thanks http://www.digip.org/blog/2011/01/generating-data-files-in-setup.py.html for the tip @@ -109,7 +143,7 @@ def run(self, *args, **kwargs): ('grumpy_runtime', 'grumpy_runtime', build_dir, built_files), ] - super_result = BuildCommand.run(self, *args, **kwargs) + super_result = BuildExtCommand.run(self, *args, **kwargs) return super_result @@ -122,7 +156,8 @@ def run(self, *args, **kwargs): ), include_package_data=True, cmdclass={ - 'build_py': BuildMakeCommand, + 'build_py': BuildMakeCommandInstall, # Ran on setup.py install + 'build_ext': BuildMakeCommandDevelop, # Ran on setup.py develop }, zip_safe=False, ) From c3b37a2959db8c81bc4aa764f5b31c8bca3a1cac Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 22 May 2018 19:09:10 -0300 Subject: [PATCH 70/73] bumpversion usage reminder --- bumpversion.readme | 1 + 1 file changed, 1 insertion(+) create mode 100644 bumpversion.readme diff --git a/bumpversion.readme b/bumpversion.readme new file mode 100644 index 00000000..1ced1baf --- /dev/null +++ b/bumpversion.readme @@ -0,0 +1 @@ +bumpversion patch --verbose --dry-run From 1b66928e1dd00e380fb8f81aab53957385c46e1b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 22 May 2018 19:09:45 -0300 Subject: [PATCH 71/73] =?UTF-8?q?Bump=20version:=200.1.6=20=E2=86=92=200.1?= =?UTF-8?q?.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- grumpy-runtime-src/grumpy_runtime/__init__.py | 2 +- grumpy-runtime-src/setup.py | 4 ++-- grumpy-tools-src/grumpy_tools/__init__.py | 2 +- grumpy-tools-src/setup.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5e652169..56fd9af0 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.6 +current_version = 0.1.7 commit = True tag = True diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py index 257520d6..e8ab86ce 100644 --- a/grumpy-runtime-src/grumpy_runtime/__init__.py +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '0.1.6' +__version__ = '0.1.7' diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index ca04bcfc..fc89b136 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -46,7 +46,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.6', + version='0.1.7', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", @@ -150,7 +150,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', requires=['grumpy_tools'], - install_requires=['grumpy-tools>=0.1.6'], + install_requires=['grumpy-tools>=0.1.7'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), diff --git a/grumpy-tools-src/grumpy_tools/__init__.py b/grumpy-tools-src/grumpy_tools/__init__.py index 1d3b22e3..ae0fb38f 100644 --- a/grumpy-tools-src/grumpy_tools/__init__.py +++ b/grumpy-tools-src/grumpy_tools/__init__.py @@ -4,4 +4,4 @@ __author__ = """Alan Justino et al.""" __email__ = 'alan.justino@yahoo.com.br' -__version__ = '0.1.6' +__version__ = '0.1.7' diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py index c211259e..bb480bcc 100644 --- a/grumpy-tools-src/setup.py +++ b/grumpy-tools-src/setup.py @@ -48,7 +48,7 @@ COMMON_OPTIONS = dict( - version='0.1.6', + version='0.1.7', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", From 2eccae730689ad9822ea437721a8613c208b4993 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 22 May 2018 19:33:35 -0300 Subject: [PATCH 72/73] Fixes the setup.py develop and the setup.py install --- grumpy-runtime-src/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index fc89b136..3007b01d 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -97,7 +97,7 @@ def run(self, *args, **kwargs): target_dir = os.path.join(self.build_lib, 'grumpy_runtime/data') # Remove the symlink used on develop - shutil.rmtree(target_dir) + shutil.rmtree(target_dir, ignore_errors=True) self.mkpath(target_dir) shutil.move('gopath', target_dir) From c7d18a4b05f2b1473bb510e8104d6835b4a2a6cb Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 22 May 2018 19:34:45 -0300 Subject: [PATCH 73/73] =?UTF-8?q?Bump=20version:=200.1.7=20=E2=86=92=200.1?= =?UTF-8?q?.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- grumpy-runtime-src/grumpy_runtime/__init__.py | 2 +- grumpy-runtime-src/setup.py | 4 ++-- grumpy-tools-src/grumpy_tools/__init__.py | 2 +- grumpy-tools-src/setup.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 56fd9af0..9f32ea7c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.7 +current_version = 0.1.8 commit = True tag = True diff --git a/grumpy-runtime-src/grumpy_runtime/__init__.py b/grumpy-runtime-src/grumpy_runtime/__init__.py index e8ab86ce..fa6142cd 100644 --- a/grumpy-runtime-src/grumpy_runtime/__init__.py +++ b/grumpy-runtime-src/grumpy_runtime/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '0.1.7' +__version__ = '0.1.8' diff --git a/grumpy-runtime-src/setup.py b/grumpy-runtime-src/setup.py index 3007b01d..64591708 100644 --- a/grumpy-runtime-src/setup.py +++ b/grumpy-runtime-src/setup.py @@ -46,7 +46,7 @@ setup_requirements += ['pytest-runner'] COMMON_OPTIONS = dict( - version='0.1.7', + version='0.1.8', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.", @@ -150,7 +150,7 @@ def run(self, *args, **kwargs): GRUMPY_RUNTIME_OPTIONS = dict( name='grumpy-runtime', requires=['grumpy_tools'], - install_requires=['grumpy-tools>=0.1.7'], + install_requires=['grumpy-tools>=0.1.8'], packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ), diff --git a/grumpy-tools-src/grumpy_tools/__init__.py b/grumpy-tools-src/grumpy_tools/__init__.py index ae0fb38f..2ecccbad 100644 --- a/grumpy-tools-src/grumpy_tools/__init__.py +++ b/grumpy-tools-src/grumpy_tools/__init__.py @@ -4,4 +4,4 @@ __author__ = """Alan Justino et al.""" __email__ = 'alan.justino@yahoo.com.br' -__version__ = '0.1.7' +__version__ = '0.1.8' diff --git a/grumpy-tools-src/setup.py b/grumpy-tools-src/setup.py index bb480bcc..6bb4f0af 100644 --- a/grumpy-tools-src/setup.py +++ b/grumpy-tools-src/setup.py @@ -48,7 +48,7 @@ COMMON_OPTIONS = dict( - version='0.1.7', + version='0.1.8', description="Grumpy Runtime & Transpiler", long_description=readme, author="Dylan Trotter et al.",