3 ms·
At a previous job, we used an even simpler solution: just download everything to a directory (called "deps") with pip install --target deps -r requirements
by icebraining 8y ago
At a previous job, we used an even simpler solution: just download everything to a directory (called "deps") with
pip install --target deps -r requirements.txt
Then running the application with
PYTHONPATH=deps python myapp.py
This was also simple to integrate with service supervisors, since most make it easy to configure a environment variable.
- jazzyjackson 8y agoMaking a note of this, didn't know about the target flag, thanks !
- ProblemFactory 8y agoVirtualenv tip: you can skip the Bash magic of calling "activate" by providing the path to the python executable. /hello/venvs/myproject/bin/python myscript.py will run myscript.py exactly as if the virtualenv was active, which is easier to configure for cron jobs and services.
- wirrbel 8y agoIf this works for you, good. I think I would be cautious giving this out as advice because you can run into problems this way with regards to different python versions. The activate script uses the python version used to setup the environment.