Skip to content

Commit 01a1eac

Browse files
committed
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 spesmilo#10018
1 parent 4616d4f commit 01a1eac

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

electrum-env

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
#!/usr/bin/env bash
22
#
3-
# This script creates a virtualenv named 'env' and installs all
3+
# This script creates a virtualenv named 'env' and installs all pinned
44
# python dependencies before activating the env and running Electrum.
55
# If 'env' already exists, it is activated and Electrum is started
6-
# without any installations. Additionally, the PYTHONPATH environment
7-
# variable is set so that system packages such as e.g. apt installed
8-
# PyQt will also be visible.
6+
# without any installations (unless the pins have changed).
97
#
10-
# By default, only pure python dependencies are installed.
11-
# If you would like more extras to be installed, do e.g.:
8+
# By default, not all optional dependencies are installed.
9+
# E.g. for hardware wallet support, do:
1210
# $ source ./env/bin/activate
13-
# $ pip install -e '.[crypto,gui,hardware]'
11+
# $ pip install -r contrib/deterministic-build/requirements-hw.txt
1412
# $ deactivate
1513

1614
set -e
1715

18-
PYTHON_VER="$(python3 -c 'import sys; print(sys.version[:3])')"
19-
2016
cd $(dirname $0)
21-
if [ -e ./env/bin/activate ]; then
17+
if [ -e ./env/bin/activate ]; then # existing venv
2218
source ./env/bin/activate
23-
# FIXME what if this is an old directory and our requirements
24-
# changed in the meantime? should run "pip install -e . --upgrade"
25-
else
19+
else # create new venv
20+
echo "Creating new venv."
2621
python3 -m venv env
2722
source ./env/bin/activate
28-
pip install -e .
23+
pip install -r contrib/deterministic-build/requirements.txt
24+
pip install -r contrib/deterministic-build/requirements-binaries.txt
25+
pip install --no-dependencies -e .
26+
echo "Done creating venv."
2927
fi
3028

31-
export PYTHONPATH="$PYTHONPATH:"\
32-
"/usr/local/lib/python${PYTHON_VER}/site-packages:"\
33-
"/usr/local/lib/python${PYTHON_VER}/dist-packages:"\
34-
"/usr/lib/python3/dist-packages:"\
35-
"/usr/lib/python${PYTHON_VER}/site-packages:"
36-
29+
# This might be an old directory and our requirements might have changed in the meantime:
30+
DEPS_CHANGED_TIME=$(stat --printf %Y contrib/deterministic-build/requirements.txt)
31+
if [ "$DEPS_CHANGED_TIME" -gt "$(stat --printf %Y env)" ] ; then
32+
echo "Detected changed requirements.txt. Updating dependencies now..."
33+
pip install -r contrib/deterministic-build/requirements.txt
34+
pip install -r contrib/deterministic-build/requirements-binaries.txt
35+
touch env
36+
echo "Done updating deps."
37+
fi
3738

3839
./run_electrum "$@"

0 commit comments

Comments
 (0)