|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | | -# This script creates a virtualenv named 'env' and installs all |
| 3 | +# This script creates a virtualenv named 'env' and installs all pinned |
4 | 4 | # python dependencies before activating the env and running Electrum. |
5 | 5 | # 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). |
9 | 7 | # |
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: |
12 | 10 | # $ source ./env/bin/activate |
13 | | -# $ pip install -e '.[crypto,gui,hardware]' |
| 11 | +# $ pip install -r contrib/deterministic-build/requirements-hw.txt |
14 | 12 | # $ deactivate |
15 | 13 |
|
16 | 14 | set -e |
17 | 15 |
|
18 | | -PYTHON_VER="$(python3 -c 'import sys; print(sys.version[:3])')" |
19 | | - |
20 | 16 | cd $(dirname $0) |
21 | | -if [ -e ./env/bin/activate ]; then |
| 17 | +if [ -e ./env/bin/activate ]; then # existing venv |
22 | 18 | 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." |
26 | 21 | python3 -m venv env |
27 | 22 | 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." |
29 | 27 | fi |
30 | 28 |
|
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 |
37 | 38 |
|
38 | 39 | ./run_electrum "$@" |
0 commit comments