2020-09-08 08:31:08 +00:00
|
|
|
#!/bin/bash
|
2014-11-02 19:06:16 +00:00
|
|
|
# Use this script to download or update all dependencies to their last
|
2011-04-15 23:28:37 +00:00
|
|
|
# developpement version.
|
2014-11-02 19:06:16 +00:00
|
|
|
# The dependencies will be located in a virtualenv, so you do not
|
2011-04-15 23:28:37 +00:00
|
|
|
# need to install them on your system at all.
|
|
|
|
|
|
|
|
# Use launch.sh to start poezio directly from here
|
|
|
|
|
2020-09-08 08:31:08 +00:00
|
|
|
set -euo pipefail
|
|
|
|
|
2014-11-02 19:06:16 +00:00
|
|
|
cd "$(dirname "$0")"
|
2015-01-15 15:46:51 +00:00
|
|
|
|
2020-09-08 08:31:08 +00:00
|
|
|
POEZIO_VENV=${POEZIO_VENV:-poezio-venv}
|
|
|
|
POEZIO_PYTHON=${POEZIO_PYTHON:-python3}
|
2017-10-06 21:45:35 +00:00
|
|
|
|
2017-10-07 18:59:38 +00:00
|
|
|
command -v "$POEZIO_PYTHON" > /dev/null 2>&1 || {
|
2017-10-06 21:45:35 +00:00
|
|
|
echo "Python executable '$POEZIO_PYTHON' not found."
|
2015-01-24 17:00:48 +00:00
|
|
|
exit 1
|
2017-10-07 18:59:38 +00:00
|
|
|
}
|
2017-10-06 21:45:35 +00:00
|
|
|
|
2017-10-07 18:59:38 +00:00
|
|
|
$POEZIO_PYTHON -c 'import venv' &> /dev/null || {
|
2020-05-01 12:53:18 +00:00
|
|
|
echo "'$POEZIO_PYTHON' venv module not found. Check that you have python (>= 3.7) installed,"
|
2017-10-06 21:45:35 +00:00
|
|
|
exit 1
|
2017-10-07 18:59:38 +00:00
|
|
|
}
|
2013-03-06 22:15:23 +00:00
|
|
|
|
2020-09-08 13:51:30 +00:00
|
|
|
# XXX: Migration from master branch to main
|
|
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
changes=$(git status --porcelain | grep -v "^??")
|
|
|
|
if [ "$branch" == "master" ]; then
|
|
|
|
echo "! WARNING !"
|
|
|
|
echo "We are changing our default branch to 'main' and we have detected"
|
|
|
|
echo "you are still using 'master'."
|
|
|
|
echo
|
|
|
|
|
|
|
|
if [ -n "$changes" ]; then
|
|
|
|
echo "! Manual action required !"
|
|
|
|
echo "There are uncommited changes in your staging area. Please sort this"
|
|
|
|
echo "out and then manually checkout the 'main' branch using 'git checkout main'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
git checkout main
|
|
|
|
echo "Automatically switched to 'main' branch."
|
|
|
|
fi
|
|
|
|
|
2011-04-15 23:28:37 +00:00
|
|
|
echo 'Updating poezio'
|
2015-12-29 19:34:33 +00:00
|
|
|
git pull --ff-only origin master || {
|
2014-11-02 19:06:16 +00:00
|
|
|
echo "The script failed to update poezio."
|
|
|
|
exit 1
|
|
|
|
}
|
2011-04-13 00:14:35 +00:00
|
|
|
|
2015-01-15 15:46:51 +00:00
|
|
|
if [ -e "$POEZIO_VENV" ]
|
2011-11-08 01:31:44 +00:00
|
|
|
then
|
2014-11-02 19:06:16 +00:00
|
|
|
# In case of a python version upgrade
|
|
|
|
echo 'Trying to upgrade the virtualenv'
|
2017-10-06 21:45:35 +00:00
|
|
|
$POEZIO_PYTHON -m venv --upgrade "$POEZIO_VENV"
|
|
|
|
$POEZIO_PYTHON -m venv --system-site-packages "$POEZIO_VENV"
|
2011-11-08 01:31:44 +00:00
|
|
|
|
2015-01-15 15:46:51 +00:00
|
|
|
. "$POEZIO_VENV/bin/activate"
|
2015-05-21 08:06:03 +00:00
|
|
|
echo 'Updating the in-venv pip'
|
|
|
|
pip install --upgrade pip
|
2020-05-01 12:53:18 +00:00
|
|
|
python3 -c 'import sys;(print("Python 3.7 or newer is required") and exit(1)) if sys.version_info < (3, 7) else exit(0)' || exit 1
|
2014-11-02 19:06:16 +00:00
|
|
|
echo 'Updating the poezio dependencies'
|
|
|
|
pip install -r requirements.txt --upgrade
|
|
|
|
echo 'Updating the poezio plugin dependencies'
|
|
|
|
pip install -r requirements-plugins.txt --upgrade
|
2011-04-13 00:14:35 +00:00
|
|
|
else
|
2015-01-15 15:46:51 +00:00
|
|
|
echo "Creating the $POEZIO_VENV virtualenv"
|
2017-10-06 21:45:35 +00:00
|
|
|
$POEZIO_PYTHON -m venv "$POEZIO_VENV"
|
|
|
|
$POEZIO_PYTHON -m venv --system-site-packages "$POEZIO_VENV"
|
2013-01-17 16:37:06 +00:00
|
|
|
|
2015-01-15 15:46:51 +00:00
|
|
|
. "$POEZIO_VENV/bin/activate"
|
|
|
|
cd "$POEZIO_VENV" # needed to download slixmpp inside the venv
|
2020-05-01 12:53:18 +00:00
|
|
|
python3 -c 'import sys;(print("Python 3.7 or newer is required") and exit(1)) if sys.version_info < (3, 7) else exit(0)' || exit 1
|
2011-04-13 00:14:35 +00:00
|
|
|
|
2014-11-02 19:06:16 +00:00
|
|
|
echo 'Installing the poezio dependencies using pip'
|
|
|
|
pip install -r "../requirements.txt"
|
|
|
|
echo 'Installing the poezio plugin dependencies using pip'
|
|
|
|
pip install -r "../requirements-plugins.txt"
|
|
|
|
cd ..
|
2011-04-13 00:14:35 +00:00
|
|
|
fi
|
2014-11-02 19:06:16 +00:00
|
|
|
|
|
|
|
make
|