From d38d6c2998187680eb90aa859da6977604754a18 Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Tue, 11 Oct 2022 15:41:45 +0000 Subject: [PATCH] Update python_vanilla for /sw/general --- .../development/python/vanilla_python-3.10.4 | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/packages/development/python/vanilla_python-3.10.4 b/packages/development/python/vanilla_python-3.10.4 index 037bdf9..6961b92 100755 --- a/packages/development/python/vanilla_python-3.10.4 +++ b/packages/development/python/vanilla_python-3.10.4 @@ -5,7 +5,8 @@ # CATEGORY="development" -PACKAGE="python/vanilla_python" +#PACKAGE="python/vanilla_python" +PACKAGE="python" VERSION="3.10.4" SHORT_VERSION="3.10" URL="https://www.python.org/" @@ -16,20 +17,19 @@ INSTALLER="Jose Gracia " # Archive A and package name P A="Python-${VERSION}.tgz" P="Python-${VERSION}" - +PYSOCKS_A="PySocks-1.7.0.tar.gz" # Other interesting configure options: #--enable-sampling \ CONFIGURE_OPTS=" \ --enable-shared - --enable-unicode=ucs4 --enable-optimizations --with-ensurepip " case $PLATFORM in -rocky|vulcan|laki|slc) +rocky|hawk|vulcan|laki|slc) ;; hazelhen) ;; @@ -39,69 +39,76 @@ esac src_postinst() { + echo "Setting symlinks ..." set_symlinks + echo "... Done setting symlinks" + echo "Setting up environment variables ..." + export LD_LIBRARY_PATH=$PREFIX/lib/:$LD_LIBRARY_PATH + export PYTHONPATH=$PREFIX/lib/python${SHORT_VERSION}/site-packages + echo "... Done setting up environment" + + echo "Bootstrapping pysocks ..." + bootstrap_pysocks + echo "... Done bootstrapping pysocks" + + echo "Installing vanilla packages ..." install_vanilla_packages - - install_share_directory + echo "... Done installing vanilla packages" + # freeze vanilla packages directory + chmod -R a-w $PREFIX/lib/python${SHORT_VERSION}/site-packages - enable_pip_site - - install_site_packages + echo "Preparing modulefile ..." + prepare_modulefile + echo "... Done preparing modulefile" echo "Stage postinst done." } +bootstrap_pysocks() { + # pysocks enables using socks5 proxys in pip; + # install pysocks without pip (sigh!) + atmp=$(mktemp -d -p $WORKDIR) + echo "##### $atmp" + pushd $atmp + + tar xvf $SRC_POOL/$PYSOCKS_A --strip=1 + $PREFIX/bin/python3 setup.py install + + popd +} + install_vanilla_packages() { # install numpy, mpi4py - export LD_LIBRARY_PATH=$PREFIX/lib/:$LD_LIBRARY_PATH - export PYTHONPATH=$PREFIX/lib/python${SHORT_VERSION}/site-packages + SITE_PROXY="socks5://localhost:4131" + PIP=$PREFIX/bin/pip3 - _PIP_SITE_INDEX_URL="http://localhost:3141/root/pypi/+simple/" export PIP_DEFAULT_TIMEOUT=2 export PIP_DISABLE_PIP_VERSION_CHECK=1 - export PIP_INDEX_URL=$_PIP_SITE_INDEX_URL + export https_proxy=$SITE_PROXY; export http_proxy=$https_proxy - $PREFIX/bin/pip install numpy scipy dask - $PREFIX/bin/pip list + $PIP install numpy scipy dask + $PIP list - # freeze site-packages directory - chmod -R a-w $PREFIX/lib/python${SHORT_VERSION}/site-packages } -install_site_packages() { - export PYTHON_SITE_HOME=$PREFIX/../../$SHORT_VERSION - echo "########### $PYTHON_SITE_HOME" - PATH=$PATH:$PYTHON_SITE_HOME/bin:$PREFIX/bin - PIP_SITE=$PYTHON_SITE_HOME/bin/pip-site - PACKAGES=$PYTHON_SITE_HOME/../share/artifacts/default_requirements.txt - [ -f "$PIP_SITE" ] && $PIP_SITE install --user -r $PACKAGES -} +prepare_modulefile() { -install_share_directory() { - # create link if shared directory does not exist - GENERAL_PYTHON=/sw/general/x86_64/development/python - PYTHON_PREFIX=$PREFIX/../../ # all python stuff is here - SHARED=$PYTHON_PREFIX/share - [ ! -d "$SHARED" ] && ln -s $GENERAL_PYTHON/share $SHARED + MODFILE=$PREFIX/../modulefiles/$VERSION.lua + MODFILE_DIR=$(dirname $MODFILE) + TEMPLATE="/sw/general/x86_64/development/python/share/template_modulefile.lua" - # report - [ -d "$SHARED" ] && echo "Share directory is present." -} + test -r $TEMPLATE || (echo "No template for modulefile, skipping"; return) -enable_pip_site() { - # create link from share/bin/pip-site into $SHORT_VERSION/bin - PYTHON_SITE_HOME=$PREFIX/../../$SHORT_VERSION - PIP_SITE=$PYTHON_SITE_HOME/bin/pip-site - mkdir -p $PYTHON_SITE_HOME/bin - [ ! -f "$PIP_SITE" ] && ln -s $PYTHON_SITE_HOME/../share/bin/pip-site $PIP_SITE - # create directory for logs - mkdir -p $PYTHON_SITE_HOME/logs + # further variables for the template + INSTALL_DATE=$(date +"%Y-%m-%d") + mkdir -p $MODFILE_DIR - # report - [ -f "$PIP_SITE" ] && echo "pip-site is present." - [ ! -f "$PIP_SITE" ] && echo "pip-site is NOT present." + # this is a dirty hack: envsubst only substitutes exported/environment variables, + # thus use compgen to export all shell variables + export $(compgen -v) + cat $TEMPLATE | envsubst > $MODFILE } src_setperms() { @@ -112,9 +119,9 @@ src_setperms() { set_symlinks() { # Adding some symlinks - # Actually PEP 394 recomments against this, but we will do it anyway + # Actually PEP 394 recommends against this, but we will do it anyway - cd $PREFIX/bin + pushd $PREFIX/bin FILES="python pip pydoc" for FILE in $FILES; do if [ ! -f $FILE ]; then @@ -127,14 +134,7 @@ set_symlinks() { if [ ! -f $FILE ]; then ln -s ${FILE} python-config fi + + popd } - -# src_build() { -# make shared add_binutils_objs -# } -# -# src_install() { -# ln -s ../$PACKAGE-$VERSION/doc . -# make install || sit_fail "Installation failed" -# }