3 ms·
What I really want is to be able to type "<magic> foo.py", where <magic> creates a list of all necessary dependencies to run foo.py. Then "<magic> run <that-lis
by sillysaurus3 9y ago
What I really want is to be able to type "<magic> foo.py", where <magic> creates a list of all necessary dependencies to run foo.py. Then "<magic> run <that-list> foo.py" would automatically do whatever voodoo needs to be done to run foo.py regardless of where you run that command.
The idea is that we all have global pip installations, which is great for hacking. I have a ton of Python scripts that depend on my pip installs. All my scripts run successfully on my box. The goal is to be able to send you one of my scripts along with <that-list>, then you can run "<magic> run <that-list> foo.py" on your box, and everything "just works."
That way there is literally zero configuration. I don't have to tell any tool anything, and it's effortless for you to run it with all the benefits of a virtualenv.
- RodericDay 9y agoSounds like Stack for Python
- wyldfire 9y agoTo do it correctly/completely is probably as hard as the halting problem. Unless foo.py is stipulated to be a leaf node. You could come up with a half baked decent try by using the ast module to find foo.py deps and indexing pypi for provided package names. Complexity lies in where package names might intersect, but this is a half baked try after all.
- e12e 9y agoIt might not be magic, but sounds a lot like zc.buildout? http://docs.buildout.org/en/latest/ http://docs.buildout.org/en/latest/ Personally, I lean towards small, simple projects that are well-served by virtualenv - but for large, complex projects I think a tool like buildout will remain necessary.
- sirn 9y agozc.buildout[1] provides this kind of magic. You put the bootstrap.py[2] inside your project to bootstrap zc.buildout itself, and run `bin/buildout` and it will do everything needed to be done as configured in the recipe/configuration file. zc.buildout is also capable of compiling C sources using hexagonit.recipe.cmmi. The magic of zc.buildout is in the recipe which is a normal Python module that allowed zc.buildout to be extended to do plenty of things (e.g. managing supervisord[3], installing postgres[4], etc.). [1]: http://www.buildout.org/en/latest/index.html http://www.buildout.org/en/latest/index.html [2]: https://github.com/buildout/buildout/blob/9a4b330338e63992dc6874ea6b4ead5e0e622e12/bootstrap/bootstrap.py https://github.com/buildout/buildout/blob/9a4b330338e63992dc... [3]: https://pypi.python.org/pypi/collective.recipe.supervisor/0.20 https://pypi.python.org/pypi/collective.recipe.supervisor/0.... [4]: https://pypi.python.org/pypi/birdhousebuilder.recipe.postgres/0.2.0 https://pypi.python.org/pypi/birdhousebuilder.recipe.postgre...
- rasca 9y agoYou should check out fades[0]. It does exactly what you are asking for. [0] https://github.com/PyAr/fades https://github.com/PyAr/fades
- rhaps0dy 9y agoSounds almost like `pip freeze > requirements.txt`. This creates a list of all your currently-installed packages, which you can install with `pip install -r requirements.txt`. The biggest problem with this though is that this will make the other person install _all_ your installed packages, rather than just the ones needed for the particular script.