12
Installing gunicorn once on the OS and reuse it between venv ?
(programming.dev)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
I don't want to make the
venvportable...I want to use the
gunicornthat is installed in onevenvaccessible to othervenvI don't think that's possible without some dirty, dirty hacks i.e adding the right paths from the other
venvto your running process. Do you want dirty hacks? Because that's just asking for trouble. If you have an application that requireslibA-v1and the gunicornvenvuseslibA-v2, you're going to have a conflict at runtime.gunicorntakes a module and a module name with a variable name. Modules are found by searching in specific paths. You can add to that search path by modifying PYTHONPATH. How it works is explained here (quite wordy).To know which path to add to
PYTHONPATH, you can either read.bin/activateand figure it out, or run something likebash -c "source ./bin/activate ; env"and it'll list all the environment variables. You can then expand (not replace) the environment variables of the current environment with those of the other environment - either inbashor inpython- up to you.As I said, dirty dirty and honestly I'd just install
gunicornin everyvenvthen you're done with it. But if you really want to, try what I explained and see how it works for you. It's good to experiment and find out first hand.Anti Commercial-AI license
Wouldn't enabling the
--system-site-packagesflag during venv creation do exactly what the OP wants, provided that gunicorn is installed as a system package (e.g. with the distro's package manager)? https://docs.python.org/3/library/venv.htmlSharing packages between venvs would be a dirty trick indeed; though sharing with
system-site-packagesshould be fine, AFAIK.Hadn't considered that. It might be the solution @SpongeB0B@programming.dev is looking for. Good shout.
Anti Commercial-AI license
Why? How many kilobytes of disk space are you going to save from that?