-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Grumpy compatible with standard python projects #17
Comments
That's a very cool idea. I have two questions.
Another option would be to assume that the packages of interest are in the PYTHONPATH and then support the following:
It could find the pymysql package by looking through the PYTHONPATH and then dump that into $GOPATH/src/grumpy/lib/pymysql. Maybe use Are there other approaches we should consider? Is there a way that we could adopt something more like |
Perhaps find already installed Python packages, grab and compile those, then bundle them together for projects that use external libraries specified in a As far as the init.py problem goes, it's probably best to stick to Python's way of module searching to make as many libraries as possible compatible |
Maybe you could implement and use setuptools find_packages. PYMSQL setup.py is something like:
|
I've started to standardize a structure for Python projects under Grumpy. The basis for this is:
In principle, this means that you can pretty easily copy sources from a Python project and build and use the Go packages. Assuming you have a GOPATH set up and grumpy tools on the PATH, something like this could work:
(Note: PyMySQL is still not supported, so this doesn't actually compile yet.) Long term I'd like to wrap these steps into something simpler, along the lines of:
But there are a bunch of steps to get there:
I'd also fold some of the other tools into the grumpy binary as subcommands including grumprun, grumpc and pydeps. |
That sounds awesome @trotterdylan! |
The standard way to install packages in the python world is the
These should entirely implement the
|
After the release v0.3.0 on the PyPI, Grumpy does:
However, it does by reusing CPython's virtualenv. It does not yet can @cristim: After v0.3.0, you can @kofalt: Do you think this issue here can be closed? Feel free to open another issue for PyMySQL anyway. |
Please note that |
Jamdagni86 fix for #17 (Support tuple args in lambda)
google#43 opened @kofalt commented on 5 Jan 2017
There wasn't an explicit ticket for this, so here goes 😀
It would be great if Grumpy could digest a python project and spit out a Go project.
I think this would make Grumpy a lot more usable in practice on existing codebases.
This means a couple things, off the top of my head:
PYTHONPATH
/VIRTUAL_ENV
environment variables__init__.py
Might be more, let me know what you think.
It seems to me that a ticket like this could use a concrete example and target. How about PyMySQL? PyMySQL is a popular, small (5.6k LOC) project that is explicitly pure-python. I had a gander through their import statements and everything seemed pretty reasonable. Notably, there are a few instances where they snag some small things from
__future__
, so that might need some implementation work. I only sawprint_function
andabsolute_import
which sounds straightforward.I think this ticket would be satisfied by something like this:
And now you have a Go library that you could import and use (it doesn't look like PyMySQL has a CLI).
This is just an example though, maybe there's a better litmus test to work towards.
Relates google#5, #9, google#23, possibly others.
Thoughts? 😄
The text was updated successfully, but these errors were encountered: