rework electrum-env script
- remove all PYTHONPATH-mangling as it keeps subtly not working on different systems - its main usecase was to use the apt installed pyqt, but I don't think that's worth the hassle - instead now all dependencies are installed in the venv via pip - well, except for libsecp - instead of installing unversioned latest deps at venv-creation-time, and then keep using those forever - the script now installs pinned deps, and detects updates to the pins and installs them again if they changed closes https://github.com/spesmilo/electrum/pull/10018
This commit is contained in:
41
electrum-env
41
electrum-env
@@ -1,38 +1,39 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# This script creates a virtualenv named 'env' and installs all
|
# This script creates a virtualenv named 'env' and installs all pinned
|
||||||
# python dependencies before activating the env and running Electrum.
|
# python dependencies before activating the env and running Electrum.
|
||||||
# If 'env' already exists, it is activated and Electrum is started
|
# If 'env' already exists, it is activated and Electrum is started
|
||||||
# without any installations. Additionally, the PYTHONPATH environment
|
# without any installations (unless the pins have changed).
|
||||||
# variable is set so that system packages such as e.g. apt installed
|
|
||||||
# PyQt will also be visible.
|
|
||||||
#
|
#
|
||||||
# By default, only pure python dependencies are installed.
|
# By default, not all optional dependencies are installed.
|
||||||
# If you would like more extras to be installed, do e.g.:
|
# E.g. for hardware wallet support, do:
|
||||||
# $ source ./env/bin/activate
|
# $ source ./env/bin/activate
|
||||||
# $ pip install -e '.[crypto,gui,hardware]'
|
# $ pip install -r contrib/deterministic-build/requirements-hw.txt
|
||||||
# $ deactivate
|
# $ deactivate
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
PYTHON_VER="$(python3 -c 'import sys; print(sys.version[:3])')"
|
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
if [ -e ./env/bin/activate ]; then
|
if [ -e ./env/bin/activate ]; then # existing venv
|
||||||
source ./env/bin/activate
|
source ./env/bin/activate
|
||||||
# FIXME what if this is an old directory and our requirements
|
else # create new venv
|
||||||
# changed in the meantime? should run "pip install -e . --upgrade"
|
echo "Creating new venv."
|
||||||
else
|
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
source ./env/bin/activate
|
source ./env/bin/activate
|
||||||
pip install -e .
|
pip install -r contrib/deterministic-build/requirements.txt
|
||||||
|
pip install -r contrib/deterministic-build/requirements-binaries.txt
|
||||||
|
pip install --no-dependencies -e .
|
||||||
|
echo "Done creating venv."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PYTHONPATH="$PYTHONPATH:"\
|
# This might be an old directory and our requirements might have changed in the meantime:
|
||||||
"/usr/local/lib/python${PYTHON_VER}/site-packages:"\
|
DEPS_CHANGED_TIME=$(stat --printf %Y contrib/deterministic-build/requirements.txt)
|
||||||
"/usr/local/lib/python${PYTHON_VER}/dist-packages:"\
|
if [ "$DEPS_CHANGED_TIME" -gt "$(stat --printf %Y env)" ] ; then
|
||||||
"/usr/lib/python3/dist-packages:"\
|
echo "Detected changed requirements.txt. Updating dependencies now..."
|
||||||
"/usr/lib/python${PYTHON_VER}/site-packages:"
|
pip install -r contrib/deterministic-build/requirements.txt
|
||||||
|
pip install -r contrib/deterministic-build/requirements-binaries.txt
|
||||||
|
touch env
|
||||||
|
echo "Done updating deps."
|
||||||
|
fi
|
||||||
|
|
||||||
./run_electrum "$@"
|
./run_electrum "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user