{ "info": { "author": "Dylan Trotter et al.", "author_email": "", "bugtrack_url": null, "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" ], "description": "# Grumpy: Go running Python\n\n[![Build Status](https://travis-ci.org/alanjds/grumpy.svg?branch=master)](https://travis-ci.org/alanjds/grumpy)\n[![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)\n\n## Overview\n\nGrumpy is a Python to Go source code transcompiler and runtime that is intended\nto be a near drop-in replacement for CPython 2.7. The key difference is that it\ncompiles Python source code to Go source code which is then compiled to native\ncode, rather than to bytecode. This means that Grumpy has no VM. The compiled Go\nsource code is a series of calls to the Grumpy runtime, a Go library serving a\nsimilar purpose to the Python C API (although the API is incompatible with\nCPython's).\n\n## Limitations\n\n### Things that will probably never be supported by Grumpy\n\n1. `exec`, `eval` and `compile`: These dynamic features of CPython are not\n supported by Grumpy because Grumpy modules consist of statically-compiled Go\n code. Supporting dynamic execution would require bundling Grumpy programs\n with the compilation toolchain, which would be unwieldy and impractically\n slow.\n\n2. C extension modules: Grumpy has a different API and object layout than\n CPython and so supporting C extensions would be difficult. In principle it's\n possible to support them via an API bridge layer like the one that\n [JyNI](http://jyni.org) provides for Jython, but it would be hard to maintain and\n would add significant overhead when calling into and out of extension\n modules.\n\n### Things that Grumpy will support but doesn't yet\n\nThere are three basic categories of incomplete functionality:\n\n1. [Language features](https://github.com/google/grumpy/wiki/Missing-features#language-features):\n Most language features are implemented with the notable exception of\n [old-style classes](http://stackoverflow.com/questions/54867/what-is-the-difference-between-old-style-and-new-style-classes-in-python).\n There are also a handful of operators that aren't yet supported.\n\n2. [Builtin functions and types](https://github.com/google/grumpy/wiki/Missing-features#builtins):\n There are a number of missing functions and types in `__builtins__` that have\n not yet been implemented. There are also a lot of methods on builtin types\n that are missing.\n\n3. [Standard library](https://github.com/google/grumpy/wiki/Missing-features#standard-libraries):\n The Python standard library is very large and much of it is pure Python, so\n as the language features and builtins get filled out, many modules will\n just work. But there are also a number of libraries in CPython that are C\n extension modules which will need to be rewritten.\n\n4. C locale support: Go doesn't support locales in the same way that C does. As such,\n some functionality that is locale-dependent may not currently work the same as in\n CPython.\n\n## Running Grumpy Programs\n\n### Pre-requisites\n\nThe commands ahead assumes that you have Golang installed and a recent\nversion of Python 2, `setuptools` and `pip`.\n\n### Method 1: binary package\n\nFor convenience, a Python package is provided from the PyPI. During install,\nmany Grumpy will be compiled and stored inside your Python installation.\n\nYou need Golang preinstalled anyway for the installation to be successful.\n\n```\npip2 install -U grumpy-runtime -I --no-cache\n(wait about 5 minutes)\necho \"print 'hello, world'\" | grumpy run\n```\n\n### Method 1: make run:\n\nThe simplest way to execute a Grumpy program is to use `make run`, which wraps a\nshell script called grumprun that takes Python code on stdin and builds and runs\nthe code under Grumpy:\n\n```\ncd grumpy-tools-src\npython2 setup.py develop\ncd ../grumpy-runtime-src\necho \"print 'hello, world'\" | make run\n```\n\n### Method 2: grumpc and grumprun:\n\nFor more complicated programs, you'll want to compile your Python source code to\nGo using grumpc (the Grumpy compiler) and then build the Go code using `go\nbuild`. Since Grumpy programs are statically linked, all the modules in a\nprogram must be findable by the Grumpy toolchain on the GOPATH. Grumpy looks for\nGo packages corresponding to Python modules in the \\_\\_python\\_\\_ subdirectory\nof the GOPATH. By convention, this subdirectory is also used for staging Python\nsource code, making it similar to the PYTHONPATH.\n\nThe first step is to set up the shell so that the Grumpy toolchain and libraries\ncan be found. From the root directory of the Grumpy source distribution run:\n\n```\ncd grumpy-tools-src\npython2 setup.py develop\ncd ../grumpy-runtime-src\nmake\nexport PATH=$PWD/build/bin:$PATH\nexport GOPATH=$PWD/build\nexport PYTHONPATH=$PWD/build/lib/python2.7/site-packages\n```\n\nYou will know things are working if you see the expected output from this\ncommand:\n\n```\ncd grumpy-runtime-src\necho 'import sys; print sys.version' | grumprun\n```\n\nNext, we will write our simple Python module into the \\_\\_python\\_\\_ directory:\n\n```\ncd grumpy-runtime-src\necho 'def hello(): print \"hello, world\"' > $GOPATH/src/__python__/hello.py\n```\n\nTo build a Go package from our Python script, run the following:\n\n```\ncd grumpy-runtime-src\nmkdir -p $GOPATH/src/__python__/hello\ngrumpc -modname=hello $GOPATH/src/__python__/hello.py > \\\n $GOPATH/src/__python__/hello/module.go\n```\n\nYou should now be able to build a Go program that imports the package\n\"\\_\\_python\\_\\_/hello\". We can also import this module into Python programs\nthat are built using grumprun:\n\n```\ncd grumpy-runtime-src\necho 'from hello import hello; hello()' | grumprun\n```\n\ngrumprun is doing a few things under the hood here:\n\n1. Compiles the given Python code to a dummy Go package, the same way we\n produced \\_\\_python\\_\\_/hello/module.go above\n2. Produces a main Go package that imports the Go package from step 1. and\n executes it as our \\_\\_main\\_\\_ Python package\n3. Executes `go run` on the main package generated in step 2.\n\n## Developing Grumpy\n\nThere are three main components and depending on what kind of feature you're\nwriting, you may need to change one or more of these.\n\n### Grumpy Tools\n\nGrumpy converts Python programs into Go programs and\n`grumpy transpile` is the CLI tool responsible for parsing Python code\nand generating Go code from it. `grumpy transpile` is written in Python\nand uses the [`pythonparser`](https://github.com/m-labs/pythonparser)\nmodule to accomplish parsing.\n\nThe CLI main entrypoint lives at `grumpy-tools-src/grumpy_tools/cli.py`.\nIt is supported by a number of Python modules in the\n`grumpy-tools-src/grumpy_tools/compiler` subdir.\n\n### Grumpy Runtime\n\nThe Go code generated by `grumpy transpile` performs operations\non data structures that represent Python objects in running Grumpy programs.\nThese data structures and operations are defined in the `grumpy` Go library\n(source is in the `grumpy-runtime-src/runtime` subdir of the source\ndistribution). This runtime is analogous to the Python C API and many of the\nstructures and operations defined by `grumpy` have counterparts in CPython.\n\n### Grumpy Standard Library\n\nMuch of the Python standard library is written in Python and thus \"just works\"\nin Grumpy. These parts of the standard library are copied from CPython 2.7\n(possibly with light modifications). For licensing reasons, these files are kept\nin the `grumpy-runtime-src/third_party` subdir.\n\nThe parts of the standard library that cannot be written in pure Python, e.g.\nfile and directory operations, are kept in the `grumpy-runtime-src/lib` subdir.\nIn CPython these kinds of modules are written as C extensions. In Grumpy they\nare written in Python but they use native Go extensions to access facilities not\notherwise available in Python.\n\n### Source Code Overview\n\n- `grumpy-tools-src/grumpy_tools/compiler`: Python package implementating Python -> Go transcompilation logic.\n- `grumpy-runtime-src/lib`: Grumpy-specific Python standard library implementation.\n- `grumpy-runtime-src/runtime`: Go source code for the Grumpy runtime library.\n- `grumpy-runtime-src/third_party/ouroboros`: Pure Python standard libraries copied from the\n [Ouroboros project](https://github.com/pybee/ouroboros).\n- `grumpy-runtime-src/third_party/pypy`: Pure Python standard libraries copied from PyPy.\n- `grumpy-runtime-src/third_party/stdlib`: Pure Python standard libraries copied from CPython.\n- `grumpy-tools-src/grumpy_tools/`: Transcompilation and utility CLI.\n\n## Contact\n\nQuestions? Comments? Drop us a line at [grumpy-users@googlegroups.com](https://groups.google.com/forum/#!forum/grumpy-users)\nor join our [Gitter channel](https://gitter.im/grumpy-devel/Lobby)", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/google/grumpy", "keywords": "grumpy_runtime", "license": "Apache Software License 2.0", "maintainer": "Alan Justino et al.", "maintainer_email": "alan.justino@yahoo.com.br", "name": "grumpy-tools", "package_url": "https://pypi.org/project/grumpy-tools/", "platform": "", "project_url": "https://pypi.org/project/grumpy-tools/", "project_urls": { "Homepage": "https://github.com/google/grumpy" }, "release_url": "https://pypi.org/project/grumpy-tools/0.3.0/", "requires_dist": null, "requires_python": "~=2.7.0", "summary": "Grumpy Runtime & Transpiler", "version": "0.3.0" }, "last_serial": 4097652, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "98132f2b4ae4bfd50c895a84d8951cbe", "sha256": "1781f9c4741e58ac590ac6e7046cc82f8e2e2a7ca9fce1fcd773733e1271a3b8" }, "downloads": -1, "filename": "grumpy_tools-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "98132f2b4ae4bfd50c895a84d8951cbe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": "~=2.7.0", "size": 92960, "upload_time": "2018-04-04T04:34:52", "url": "https://files.pythonhosted.org/packages/83/2e/64227d7654eea16d181b633663e4d6eb72f04af05980387c759748e04910/grumpy_tools-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72996f8aeff9605bcf78042b10afa699", "sha256": "7c0c49251b43d162313c773a1f26cdbf250fafedba7b0ac2bdfee280b57f186c" }, "downloads": -1, "filename": "grumpy-tools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "72996f8aeff9605bcf78042b10afa699", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 70868, "upload_time": "2018-04-04T04:34:53", "url": "https://files.pythonhosted.org/packages/7d/51/0d52ceffe3a9c1c0ab0143d7084d49a36f324a8b1eea45d921c205b5e94b/grumpy-tools-0.1.0.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "df5fd13b6b3b42d046968ff0f3906185", "sha256": "49635c11e9fd13e16025ce24dfd447f22f86f0007dd17ef41a7292d4ce5aaa7f" }, "downloads": -1, "filename": "grumpy-tools-0.1.4.tar.gz", "has_sig": false, "md5_digest": "df5fd13b6b3b42d046968ff0f3906185", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 70952, "upload_time": "2018-05-16T22:17:29", "url": "https://files.pythonhosted.org/packages/33/4f/5d7817eb82575bfef49e8ecc2aa3680e2a796cc5a857f26dd6298ff68eb2/grumpy-tools-0.1.4.tar.gz" } ], "0.1.4.1": [ { "comment_text": "", "digests": { "md5": "948ea533159f2b07cf1f9ac01bd9815f", "sha256": "b2db3637585ccbe5c67911ae22c0486bea4eac752f196851ae3914a457eb73d5" }, "downloads": -1, "filename": "grumpy-tools-0.1.4.1.tar.gz", "has_sig": false, "md5_digest": "948ea533159f2b07cf1f9ac01bd9815f", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 70973, "upload_time": "2018-05-16T22:36:32", "url": "https://files.pythonhosted.org/packages/de/7f/891695308fbad7a8f664dd578f1a9d9fb7085688ac2e5c9c1cbab0e64b7f/grumpy-tools-0.1.4.1.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "a55631c082fe650c3c9314359190eb73", "sha256": "a8141bc2af534b15151fcc73c6e7580ab6fa58a2ecec01a4b84c334463abe67d" }, "downloads": -1, "filename": "grumpy-tools-0.1.5.tar.gz", "has_sig": false, "md5_digest": "a55631c082fe650c3c9314359190eb73", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 71520, "upload_time": "2018-05-16T22:40:18", "url": "https://files.pythonhosted.org/packages/8c/24/0edd2efb6d2b3b93fc24cf246d57dfd4211af2bfbdff539268edfcff69cc/grumpy-tools-0.1.5.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "c255aee65f993d757e3aa4ab760b0547", "sha256": "aa3184d704ed3024a491b07bcd242a310621f334d8095ef895e015910bf800fc" }, "downloads": -1, "filename": "grumpy-tools-0.1.8.tar.gz", "has_sig": false, "md5_digest": "c255aee65f993d757e3aa4ab760b0547", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 71147, "upload_time": "2018-05-22T22:36:15", "url": "https://files.pythonhosted.org/packages/bc/13/7b7410fcb64087ae30648699c306adb960fd4d09cbd22da6e384f0d33bd9/grumpy-tools-0.1.8.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "978523522a4702d7fbbeac4a4d714848", "sha256": "5383bf3efccf8d1780929a603c57306f764adc7168d35d00f3e6984e9ccff21c" }, "downloads": -1, "filename": "grumpy-tools-0.2.0.tar.gz", "has_sig": false, "md5_digest": "978523522a4702d7fbbeac4a4d714848", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 75442, "upload_time": "2018-06-25T13:11:32", "url": "https://files.pythonhosted.org/packages/c9/ea/50f9129a6b6881a8c82fe8e7670294058969302c340dc8cc98da8ea4848c/grumpy-tools-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c68684d07e29f584ec6b8e242f4f02ff", "sha256": "745ea2fe3e747ac78c3827786d1286b825d65be7c3653aa7a2c3fa3c3e5ae15a" }, "downloads": -1, "filename": "grumpy-tools-0.2.1.tar.gz", "has_sig": false, "md5_digest": "c68684d07e29f584ec6b8e242f4f02ff", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 75923, "upload_time": "2018-07-07T18:20:04", "url": "https://files.pythonhosted.org/packages/4b/0e/3b686da6ba44a1062e161256a9419e8a6af2df895fdf1e13965f7b09661b/grumpy-tools-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "e18d8899c927d9b63ad63dcdbda6ae0e", "sha256": "d355bc45bd6b2d460e965d4e3c1de7b92f3e5316679ff96fff1eb1fa9eb05833" }, "downloads": -1, "filename": "grumpy-tools-0.2.2.tar.gz", "has_sig": false, "md5_digest": "e18d8899c927d9b63ad63dcdbda6ae0e", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 75939, "upload_time": "2018-07-10T17:45:25", "url": "https://files.pythonhosted.org/packages/8e/f8/8ff5cbd8dd02c82da1ba3f2b03a114a0ce69eec583bcb4f7127c94b9b1b1/grumpy-tools-0.2.2.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "e8b788d375267798c0285f8baeae951c", "sha256": "e41cb6a5788e325bc702ef88f647f3d8763d1f34e3b63e287f0df1bf44dd26ae" }, "downloads": -1, "filename": "grumpy-tools-0.3.0.tar.gz", "has_sig": false, "md5_digest": "e8b788d375267798c0285f8baeae951c", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 76047, "upload_time": "2018-07-24T16:42:00", "url": "https://files.pythonhosted.org/packages/77/cd/68ed43ad2bce4ba99c76e3a802b72d843701c66deb27619f028b603a4b27/grumpy-tools-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e8b788d375267798c0285f8baeae951c", "sha256": "e41cb6a5788e325bc702ef88f647f3d8763d1f34e3b63e287f0df1bf44dd26ae" }, "downloads": -1, "filename": "grumpy-tools-0.3.0.tar.gz", "has_sig": false, "md5_digest": "e8b788d375267798c0285f8baeae951c", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7.0", "size": 76047, "upload_time": "2018-07-24T16:42:00", "url": "https://files.pythonhosted.org/packages/77/cd/68ed43ad2bce4ba99c76e3a802b72d843701c66deb27619f028b603a4b27/grumpy-tools-0.3.0.tar.gz" } ] }