In order to bring back some sanity to my machine (or so I thought…) I decided to rely solely on pyenv to handle all my python versions (i.e. no more python from brew for instance).
So I naively created a virtualenv for Alice (based first on python 3.7.3 and then on 3.6.5 with the same result), and tried aliBuild --defaults o2 build O2.
Unfortunately the build fails in Python-modules with some obscure (to me at least) message about “python not being installed as a framework”
Was the pyenv + virtualenv a bad idea from the start or is the error just a glitch that’s easy to fix ?
I’m also using virtualenv on my system. For this I had to modify python-modules.sh.
It is mainly removing the --user and all cleanup of the local installation:
diff --git a/python-modules.sh b/python-modules.sh
index 13caefd..c5ded85 100644
--- a/python-modules.sh
+++ b/python-modules.sh
@@ -53,7 +53,10 @@ fi
for P in "${PIP_REQUIREMENTS[@]}"; do
echo $P | cut -d' ' -f1
done > requirements.txt
-env PYTHONUSERBASE="$INSTALLROOT" pip3 install --user -IU -r requirements.txt
+if [ -n "$VIRTUAL_ENV" ]; then
+ env PYTHONUSERBASE="$INSTALLROOT" pip3 install -IU -r requirements.txt
+else
+ env PYTHONUSERBASE="$INSTALLROOT" pip3 install --user -IU -r requirements.txt
# Find the proper Python lib library and export it
pushd "$INSTALLROOT"
@@ -69,6 +72,7 @@ pushd "$INSTALLROOT"
rm -f *.deleteme || true
popd
popd
+fi
# Check if the modules can be loaded
ERR_IMPORT=()
@@ -89,7 +93,11 @@ fi
MATPLOTLIB_TAG="3.0.3"
if [[ $ARCHITECTURE != slc* ]]; then
# Simply get it via pip in most cases
+if [ -n "$VIRTUAL_ENV" ]; then
+ env PYTHONUSERBASE=$INSTALLROOT pip3 install "matplotlib==$MATPLOTLIB_TAG"
+else
env PYTHONUSERBASE=$INSTALLROOT pip3 install --user "matplotlib==$MATPLOTLIB_TAG"
+fi
else
# We are on a RHEL-compatible OS. We compile it ourselves, and link it to our dependencies
@@ -126,6 +134,7 @@ fi
env PYTHONPATH="$INSTALLROOT/lib/python/site-packages" python3 -c 'import matplotlib'
# Patch long shebangs (by default max is 128 chars on Linux)
+if [ -z "$VIRTUAL_ENV" ]; then
pushd "$INSTALLROOT/bin"
sed -i.deleteme -e '1 s|^#!.*$|#!/usr/bin/env python3|' * || true
rm -f *.deleteme
@@ -136,6 +145,7 @@ rm -rvf "$INSTALLROOT"/share "$INSTALLROOT"/lib/python*/test
find "$INSTALLROOT"/lib/python* \
-mindepth 2 -maxdepth 2 -type d -and \( -name test -or -name tests \) \
-exec rm -rvf '{}' \;
+fi
# Modulefile
MODULEDIR="$INSTALLROOT/etc/modulefiles"
The situation with LHAPDF is a bit more complex. In a nutshell it’s not python3 ready (yet). So I’ve disabled the building of the python extension if only Python3 is available to the build https://github.com/alisw/alidist/pull/1623
In my case I did not have to change python-modules. As far as I can tell python-modules.sh installs stuff into its own (user) location, so it should not interfere at all with virtualenvs ?