sit/packages/development/python/vanilla_python-3.10.4

140 lines
2.9 KiB
Bash
Executable file

#!/bin/sh
# sit class file
#
# Christoph Niethammer <niethammer@hlrs.de> (C) 2018
#
CATEGORY="development"
#PACKAGE="python/vanilla_python"
PACKAGE="python"
VERSION="3.10.4"
SHORT_VERSION="3.10"
URL="https://www.python.org/"
INSTALLER="Jose Gracia <gracia@hlrs.de>"
# 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-optimizations
--with-ensurepip
"
case $PLATFORM in
rocky|hawk|vulcan|laki|slc)
;;
hazelhen)
;;
*)
;;
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
echo "... Done installing vanilla packages"
# freeze vanilla packages directory
chmod -R a-w $PREFIX/lib/python${SHORT_VERSION}/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
SITE_PROXY="socks5://localhost:4131"
PIP=$PREFIX/bin/pip3
export PIP_DEFAULT_TIMEOUT=2
export PIP_DISABLE_PIP_VERSION_CHECK=1
export https_proxy=$SITE_PROXY; export http_proxy=$https_proxy
$PIP install numpy scipy dask
$PIP list
}
prepare_modulefile() {
MODFILE=$PREFIX/../modulefiles/$VERSION.lua
MODFILE_DIR=$(dirname $MODFILE)
TEMPLATE="/sw/general/x86_64/development/python/share/template_modulefile.lua"
test -r $TEMPLATE || (echo "No template for modulefile, skipping"; return)
# further variables for the template
INSTALL_DATE=$(date +"%Y-%m-%d")
mkdir -p $MODFILE_DIR
# 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() {
chmod -R g=u $PREFIX
chmod -R o=u-w $PREFIX
}
set_symlinks() {
# Adding some symlinks
# Actually PEP 394 recommends against this, but we will do it anyway
pushd $PREFIX/bin
FILES="python pip pydoc"
for FILE in $FILES; do
if [ ! -f $FILE ]; then
if [ -f ${FILE}3 ]; then
ln -s ${FILE}3 ${FILE}
fi
fi
done
FILE="python3-config"
if [ ! -f $FILE ]; then
ln -s ${FILE} python-config
fi
popd
}