From a83805e00b39e7a621f7181ca31632e97a4ae615 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 11 Dec 2020 15:53:33 +0100 Subject: [PATCH] tweak electrum-env script - set -e, and don't call deactivate (not needed; and with -e if ./run_electrum errors it wouldn't run anyway) - re PYTHONPATH - I think the sane thing is to give priority to the virtualenv, and only use system-packages as a fallback - added more paths; tested that it now works for modern Ubuntu and Manjaro - use "python3 -m venv" instead of "virtualenv" (as former is always(?) available now) --- electrum-env | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/electrum-env b/electrum-env index 772131a9d..163961546 100755 --- a/electrum-env +++ b/electrum-env @@ -4,24 +4,36 @@ # python dependencies before activating the env and running Electrum. # If 'env' already exists, it is activated and Electrum is started # without any installations. Additionally, the PYTHONPATH environment -# variable is set properly before running Electrum. +# variable is set so that system packages such as e.g. apt installed +# PyQt5 will also be visible. # -# python-qt and its dependencies will still need to be installed with -# your package manager. +# By default, only pure python dependencies are installed. +# If you would like more extras to be installed, do e.g.: +# $ source ./env/bin/activate +# $ pip install -e '.[crypto,gui,hardware]' +# $ deactivate + +set -e PYTHON_VER="$(python3 -c 'import sys; print(sys.version[:3])')" cd $(dirname $0) if [ -e ./env/bin/activate ]; then source ./env/bin/activate + # FIXME what if this is an old directory and our requirements + # changed in the meantime? should run "pip install -e . --upgrade" else - virtualenv env -p `which python3` + python3 -m venv env source ./env/bin/activate - python3 -m pip install .[fast] + pip install -e . fi -export PYTHONPATH="/usr/local/lib/python${PYTHON_VER}/site-packages:$PYTHONPATH" +export PYTHONPATH="$PYTHONPATH:"\ +"/usr/local/lib/python${PYTHON_VER}/site-packages:"\ +"/usr/local/lib/python${PYTHON_VER}/dist-packages:"\ +"/usr/lib/python3/dist-packages:"\ +"/usr/lib/python${PYTHON_VER}/site-packages:"\ +"${HOME}/.local/lib/python${PYTHON_VER}/site-packages" -./run_electrum "$@" -deactivate +./run_electrum "$@"