This moment, I am using pyenv + venv to manage Python versions and specific libraries. My project layout looks like this:
My goal is, once venv is activated dir1 and dir2 to be inside sys.path. Basically, I solve this task but I really do not like solution. I added custom PYTHONPATH inside venv under bin/activate file and everything works fine. This is not so flexible from deployment point of view. Does venv provide some hooks for this ? For example: set customer environment variables once venv is activated or run some function or something like this. I do not like idea, to modify bin/activate file on every machine.
P.S I know about packaging stuff and setuptools, but for this project I can not use it.
Any ideas ?
Thanks !
Another possibility (which is usually what I use and avoids going into you venv source code) :
Create an activate.sh script where you export path to your modules AND activate venv ie :
source venv/bin/activate
export PYTHONPATH=$PYTHONPATH:$(pwd)
then you can just do source activate.sh instead of source venv/bin/activate and you will have both actions at once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With