From 3ff83f5962740076c4575a333242faf9ee9d001f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 21 Dec 2018 08:51:45 +0100 Subject: [PATCH] Migrate to python3 --- scripts/_common.sh | 1 + scripts/install | 19 +++++++------------ scripts/restore | 2 +- scripts/upgrade | 25 ++++++++++++++++--------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index e69de29..6cac827 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -0,0 +1 @@ +dependances="coturn build-essential python3-dev libffi-dev python3-pip python3-setuptools sqlite3 libssl-dev python3-venv libxml2-dev libxslt1-dev python3-lxml libjpeg-dev libpq-dev postgresql acl" diff --git a/scripts/install b/scripts/install index f227bdb..66c63b3 100644 --- a/scripts/install +++ b/scripts/install @@ -92,8 +92,8 @@ ynh_app_setting_set $app cli_port $cli_port # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -ynh_install_app_dependencies coturn build-essential python2.7-dev libffi-dev python-pip python-setuptools sqlite3 libssl-dev python-virtualenv libxml2-dev libxslt1-dev python-lxml libjpeg-dev libpq-dev postgresql acl -pip install --upgrade virtualenv +ynh_install_app_dependencies $dependances +pip3 install --upgrade virtualenv #================================================= # CREATE DEDICATED USER @@ -138,7 +138,7 @@ then ynh_setup_source $final_path/ "armv7_$(lsb_release --codename --short)" else # Install virtualenv if it don't exist - test -e $final_path/bin || virtualenv -p python2.7 $final_path + test -e $final_path/bin/python3 || python3 -m venv $final_path # Install synapse in virtualenv PS1=${PS1:-} @@ -147,17 +147,12 @@ else # We set all necessary environement variable to create a python virtualenvironnement. source $final_path/bin/activate - pip install --upgrade pip - pip install --upgrade setuptools - pip install --upgrade cffi ndg-httpsclient psycopg2 lxml + pip3 install --upgrade pip + pip3 install --upgrade setuptools + pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml ynh_setup_source "/tmp" "python_source" - pip install --upgrade "/tmp/synapse_source.tar.gz" - - # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 - test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ - pip uninstall -y msgpack-python msgpack; \ - pip install msgpack-python) + pip3 install --upgrade "/tmp/synapse_source.tar.gz" # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does deactivate diff --git a/scripts/restore b/scripts/restore index 1da0302..6b30cb9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -59,7 +59,7 @@ ynh_restore # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files -ynh_install_app_dependencies coturn build-essential python2.7-dev libffi-dev python-pip python-setuptools sqlite3 libssl-dev python-virtualenv libxml2-dev libxslt1-dev python-lxml libjpeg-dev libpq-dev postgresql acl +ynh_install_app_dependencies $dependances pip install --upgrade virtualenv #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index deede78..48190a4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,12 +74,24 @@ fi #================================================= # STANDARD UPGRADE STEPS +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE +# For any update do it in all files +ynh_install_app_dependencies $dependances +pip install --upgrade virtualenv + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= # Install/upgrade synapse in virtualenv +# Clean venv is it was on python2.7 +test -e $final_path/bin/python3 || ynh_secure_remove $final_path + # WARNING : these commands are used in INSTALL, UPGRADE # For any update do it in all files @@ -88,7 +100,7 @@ then ynh_setup_source $final_path/ "armv7_$(lsb_release --codename --short)" else # Install virtualenv if it don't exist - test -e $final_path/bin || virtualenv -p python2.7 $final_path + test -e $final_path/bin/python3 || python3 -m venv $final_path # Install synapse in virtualenv PS1=${PS1:-} @@ -97,17 +109,12 @@ else # We set all necessary environement variable to create a python virtualenvironnement. source $final_path/bin/activate - pip install --upgrade setuptools - pip install --upgrade cffi ndg-httpsclient psycopg2 lxml + pip3 install --upgrade setuptools + pip3 install --upgrade cffi ndg-httpsclient psycopg2 lxml # Download and check the checksum for the synapse source ynh_setup_source "/tmp" "python_source" - pip install --upgrade "/tmp/synapse_source.tar.gz" - - # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 - test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ - pip uninstall -y msgpack-python msgpack; \ - pip install msgpack-python) + pip3 install --upgrade "/tmp/synapse_source.tar.gz" # This function was defined when we called "source $final_path/bin/activate". With this function we undo what "$final_path/bin/activate" does deactivate