sit/packages/development/python/vanilla_python-3.10.4

141 lines
2.9 KiB
Groff
Raw Permalink Normal View History

2022-08-04 09:06:44 +00:00
#!/bin/sh
# sit class file
#
# Christoph Niethammer <niethammer@hlrs.de> (C) 2018
#
CATEGORY="development"
2022-10-11 15:41:45 +00:00
#PACKAGE="python/vanilla_python"
PACKAGE="python"
2022-08-04 09:06:44 +00:00
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}"
2022-10-11 15:41:45 +00:00
PYSOCKS_A="PySocks-1.7.0.tar.gz"
2022-08-04 09:06:44 +00:00
# Other interesting configure options:
#--enable-sampling \
CONFIGURE_OPTS=" \
--enable-shared
--enable-optimizations
--with-ensurepip
"
case $PLATFORM in
2022-10-11 15:41:45 +00:00
rocky|hawk|vulcan|laki|slc)
2022-08-04 09:06:44 +00:00
;;
hazelhen)
;;
*)
;;
esac
src_postinst() {
2022-10-11 15:41:45 +00:00
echo "Setting symlinks ..."
2022-08-04 09:06:44 +00:00
set_symlinks
2022-10-11 15:41:45 +00:00
echo "... Done setting symlinks"
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
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"
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
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
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
echo "Preparing modulefile ..."
prepare_modulefile
echo "... Done preparing modulefile"
2022-08-04 09:06:44 +00:00
echo "Stage postinst done."
}
2022-10-11 15:41:45 +00:00
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
}
2022-08-04 09:06:44 +00:00
install_vanilla_packages() {
# install numpy, mpi4py
2022-10-11 15:41:45 +00:00
SITE_PROXY="socks5://localhost:4131"
PIP=$PREFIX/bin/pip3
2022-08-04 09:06:44 +00:00
export PIP_DEFAULT_TIMEOUT=2
export PIP_DISABLE_PIP_VERSION_CHECK=1
2022-10-11 15:41:45 +00:00
export https_proxy=$SITE_PROXY; export http_proxy=$https_proxy
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
$PIP install numpy scipy dask
$PIP list
2022-08-04 09:06:44 +00:00
}
2022-10-11 15:41:45 +00:00
prepare_modulefile() {
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
MODFILE=$PREFIX/../modulefiles/$VERSION.lua
MODFILE_DIR=$(dirname $MODFILE)
TEMPLATE="/sw/general/x86_64/development/python/share/template_modulefile.lua"
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
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
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
# 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
2022-08-04 09:06:44 +00:00
}
src_setperms() {
chmod -R g=u $PREFIX
chmod -R o=u-w $PREFIX
}
set_symlinks() {
# Adding some symlinks
2022-10-11 15:41:45 +00:00
# Actually PEP 394 recommends against this, but we will do it anyway
2022-08-04 09:06:44 +00:00
2022-10-11 15:41:45 +00:00
pushd $PREFIX/bin
2022-08-04 09:06:44 +00:00
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
2022-10-11 15:41:45 +00:00
popd
}
2022-08-04 09:06:44 +00:00