Utilisation d'un virtualenv

This commit is contained in:
Martin Pépin 2016-11-06 15:39:50 +01:00
parent 0cca9f0861
commit 41b54cec9e
3 changed files with 15 additions and 9 deletions

View file

@ -8,7 +8,7 @@ DBNAME="cof_gestion"
DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4"
# Installation de paquets utiles
apt-get update && apt-get install -y mercurial python-pip python-dev \
apt-get update && apt-get install -y mercurial python3-pip python3-dev \
libmysqlclient-dev libjpeg-dev git redis-server
# Configuration et installation de mysql. Le mot de passe root est le même que
@ -44,6 +44,9 @@ export DBPASSWD="$DBPASSWD"
# Permet d'utiliser les utilitaires pythons locaux
export PATH="\$PATH:\$HOME/.local/bin"
# Charge le virtualenv
source ~/venv/bin/activate
# On va dans /vagrant où se trouve le code de gestioCOF
cd /vagrant
EOF
@ -52,8 +55,11 @@ chown vagrant: ~vagrant/.bash_profile
# On va dans /vagrant où se trouve gestioCOF
cd /vagrant
# Installation des dépendances python
sudo -H -u vagrant pip install --user -r requirements.txt -r requirements-devel.txt
# Installation du virtualenv, on utilise désormais python3
pip3 install -U pip
pip3 install virtualenv
sudo -H -u vagrant virtualenv ~vagrant/venv -p /usr/bin/python3
sudo -H -u vagrant ~vagrant/venv/bin/pip install -r requirements.txt -r requirements-devel.txt
# Préparation de Django
sudo -H -u vagrant DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNAME=$DBNAME DBPASSWD=$DBPASSWD sh provisioning/prepare_django.sh
@ -62,7 +68,7 @@ sudo -H -u vagrant DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNA
sudo -H -u vagrant crontab provisioning/cron.dev
# On installe Daphne et on demande à supervisor de le lancer
pip install daphne
~vagrant/venv/bin/pip install daphne
apt-get install -y supervisor
cp /vagrant/provisioning/supervisor.conf /etc/supervisor/conf.d/gestiocof.conf
sed "s/{DBUSER}/$DBUSER/" -i /etc/supervisor/conf.d/gestiocof.conf

View file

@ -1,5 +1,5 @@
# Doit être lancé par bootstrap.sh
python manage.py migrate
python manage.py loaddata users root bda gestion sites
python manage.py collectstatic --noinput
~/venv/bin/python manage.py migrate
~/venv/bin/python manage.py loaddata users root bda gestion sites
~/venv/bin/python manage.py collectstatic --noinput

View file

@ -1,5 +1,5 @@
[program:worker]
command=/usr/bin/python /vagrant/manage.py runworker
command=/home/vagrant/venv/bin/python /vagrant/manage.py runworker
directory=/vagrant/
user=vagrant
environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev"
@ -10,7 +10,7 @@ stopasgroup=true
redirect_stderr=true
[program:interface]
command=/usr/local/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer
command=/home/vagrant/venv/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer
environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev"
directory=/vagrant/
redirect_stderr=true