diff --git a/python-modules.sh b/python-modules.sh index 371bb6c7b1..ea434081a8 100644 --- a/python-modules.sh +++ b/python-modules.sh @@ -13,10 +13,43 @@ prepend_path: # If we need tensorflow-metal to work on Mac during subsequent builds, we # must use lib/python$pyver, not lib/python here. PYTHONPATH: "$PYTHON_MODULES_ROOT/lib/python/site-packages" +prefer_system: ".*" +prefer_system_check: | + # if we are in a virtualenv, assume people know what they are doing + # and simply use the virtualenv recipe. + if [ -n "$VIRTUAL_ENV" ]; then + echo "alibuild_system_replace: virtualenv" + exit 0 + fi + # If not, either they are using the system python or they are using our own python. + # In both cases we can simply create our own virtualenv + exit 1 +prefer_system_replacement_specs: + virtualenv: + version: "virtualenv" + recipe: | + # Install pinned basic requirements for python infrastructure + echo "$PIP_BASE_REQUIREMENTS" > base-requirements.txt + python3 -m pip install -IU -r base-requirements.txt + # The above updates pip and setuptools, so install the rest of the packages separately. + echo "$PIP_REQUIREMENTS" > requirements.txt + python3 -m pip install -IU -r requirements.txt + # We do not need anything else, because python is going to be in path + # if we are inside a virtualenv so no need to pretend we know where + # the correct python is. + + # We generate the modulefile to avoid complains by dependencies + mkdir -p "$INSTALLROOT/etc/modulefiles" + alibuild-generate-module --bin > "$INSTALLROOT/etc/modulefiles/$PKGNAME" + requires: + - "FreeType:(?!osx)" + - libpng + - hdf5 + build_requires: + - Python-modules-list + - alibuild-recipe-tools --- #!/bin/bash -e -unset VIRTUAL_ENV - # Users might want to install more packages in the same environment. A venv # provides a pip binary that will install packages into the same path. # This copies the system python binary (or the one from PYTHON_ROOT) into the @@ -50,9 +83,6 @@ find "$INSTALLROOT" -mindepth 2 -maxdepth 2 \ find "$INSTALLROOT"/bin -type f -exec sed -r -i.deleteme -e "1s,^#!$INSTALLROOT/bin/,#!/usr/bin/env ," {} \; rm -f "$INSTALLROOT"/bin/*.deleteme -# Link python -> python$pyver, so we can refer to it in PYTHONPATH without knowing pyver. -ln -nsf "python$pyver" "$INSTALLROOT/lib/python" - # Modulefile mkdir -p "$INSTALLROOT/etc/modulefiles" alibuild-generate-module --bin > "$INSTALLROOT/etc/modulefiles/$PKGNAME" diff --git a/xjalienfs.sh b/xjalienfs.sh index fe720da2ce..cded443d7f 100644 --- a/xjalienfs.sh +++ b/xjalienfs.sh @@ -12,6 +12,47 @@ build_requires: - alibuild-recipe-tools prepend_path: PYTHONPATH: ${XJALIENFS_ROOT}/lib/python/site-packages +prefer_system: ".*" +prefer_system_check: | + # if we are in a virtualenv, assume people know what they are doing + # and simply use the virtualenv recipe. + if [ ! -z $VIRTUAL_ENV ]; then + echo "alibuild_system_replace: virtualenv" + exit 0 + fi + # If not, either they are using the system python or they are using our own python. + # In both cases we can simply create our own virtualenv + exit 1 +prefer_system_replacement_specs: + virtualenv: + recipe: | + #!/bin/bash -e + + # Use pip's --target to install under $INSTALLROOT without weird hacks. This + # works inside and outside a virtualenv, but unset VIRTUAL_ENV to make sure we + # only depend on stuff we installed using our Python and Python-modules. + + # on macos try to install gnureadline and just skip if fails (alienpy can work without it) + # macos python readline implementation is build on libedit which does not work + [[ "$ARCHITECTURE" == osx_* ]] && { \ + python3 -m pip install --force-reinstall \ + gnureadline || : ; } + + env ALIBUILD=1 \ + python3 -m pip install --force-reinstall \ + "file://$SOURCEDIR/../$PKG_VERSION" + # We do not need anything else, because python is going to be in path + # if we are inside a virtualenv so no need to pretend we know where + # the correct python is. + + # We generate the modulefile to avoid complains by dependencies + mkdir -p "$INSTALLROOT/etc/modulefiles" + alibuild-generate-module --bin > "$INSTALLROOT/etc/modulefiles/$PKGNAME" + requires: + - XRootD + - AliEn-Runtime + build_requires: + - alibuild-recipe-tools --- #!/bin/bash -e