Single File, Editable Python Scripts with Dependencies
franzoni.euIt's virtually equivalent to virtualenv. Virtualenv creation, installation and activation can be scripted. Why shouldn't we use the real thing?
Feel free to use what you feel is good for you. But this makes a lot of sense (to me!) for simpler scripts. Imagine cron jobs or other "internal" scripts, maybe things that you launch on a cluster via ansible or other tools for periodic or one shot tasks... things like that.
Virtualenv is "stateful" - you need a) to have it installed on the target system b) to deliver both your script AND the requirements.txt file c) to launch virtualenv d) execute your script via virtualenv.
Far more complex than just "run this script and you're done", right? If an "embedded virtualenv" functionality existed, something like
Then my snippet would make no sense.import virtualenv virtualenv.install_requirements("asd==1.2.3") # from there, the software goes on with the requirements actually availableOf course (but I don't know whether this was the real suggestion) I could evaluate using virtualenv (if available) instead of manually setting the sys.path. But I found that to be a bit more complex (virtualenv could actually be installed with a different Python interpreter since it allows the -p parameter, while pip is generally bound to each specific interpreter).