Hi,
I have quite few venv
that run gunicorn.
I would like to reuse gunicorn
for other venv
I launch my web application like this
#PWD = venv dir
source ./bin/activate
gunicorn A_WebApp:app
#A_WebApp is my python file A_WebApp.py
I supposes that gunicorn
is a shell program ? if yes I should use $PATH
?
or gunicorn
is a Python program only ? and then what I should do to use gunicorn in another venv
?
Thanks.
If A_WebApp is truly the python file and app is some python symbol then you should be able to make gunicorn in another venv and call your script as such:
path/to/venv/bin/python gunicorn A_Web_App:app
Thank you ! it works !
Actually this is working :
path/to/venv/bin/gunicorn A_Web_App:app
Some other poster, claim it’s dirty… but which problems could it generate ? (if any)
Thanks all !!!
I don’t think it’s dirty if you manage your requirements across these environments with care, but I’d ask for what they mean
It’s possible to make the venv portable, versionize it, archive it and deploy at boot the latest version. It’s architecture dependent though, so if you deploy on multiple archs, you will need to build for each.
Edit: gunicorn is part of the venv. All you need to do after deploying gunicorn is activating the venv and running your server.
You can also have the archive tun through several vulnerability checkers.
I don’t want to make the
venv
portable…
I want to use thegunicorn
that is installed in onevenv
accessible to othervenv
Removed by mod
Wouldn’t enabling the
--system-site-packages
flag 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-packages
should be fine, AFAIK.Removed by mod
Why? How many kilobytes of disk space are you going to save from that?
Use pip to install pipx, use pipx to install gunicorn to make it available globally. Pipx is meant to install applications as it will install each in their own venv, whereas pip will install them in a single global env.
Makes sure gunicorn isn’t installed in your venvs, so when you run them, they’ll use the pipx installed one.
I wouldn’t recommend it. Installing Python packages not in a venv is asking for trouble. Why do you care anyway?