c3cris c3cris - 1 year ago 81
Git Question

Best practice to deploy python app to use a specific version of Python with venv

I am done with a project and it has been been pushed to git but the client wants VENV. I already got

to work and created a

My question is what is the best practice for a deployment workflow. So far this is what I created as a deploy workflow:

git clone ssh://myawesomerepo
cd myawesomerepo
pip install virtualenv
venv -python=python3.5 env
source env/bin/activate
pip install -r requirements.txt
python run.py

Is this the correct workflow?

Assuming that we don't know what version of python the client has. My project is written for python 3.5, and if the client has 2.7 will this work?*

Answer Source

I use the following bash script to install my python applications: I check for either versions of pip ( 2.x or 3.x ) if they are in PATH:

if [ command -v pip3 >/dev/null 2>&1  ]; 
    echo "installing virtual env with pip3"
    pip3 install virtualenv
    echo "installing virtual env with pip"
    pip install virtualenv

echo "Installing python 3.5 bin"
virtualenv --python=python3.5 env

echo "Activate virtual env"
source env/bin/activate

echo "Installing requirements"
pip install -r requirements.txt
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download