python_3.9.def 3.27 KB
Bootstrap: docker
From: centos:8

%help 
This is a singularity container packing a python 3.9.6 (only version) environment with all the packages necessary to execute all the python scripts present in the version 2.10.0 of the gad pipeline.
Python v3.9.6 is the latest available version in CentOS v8.5.211 used for this build.
Authors : valentin.vautrot@u-bourgogne.fr

python3.9.6 is installed in /usr/bin/python3.9/

non-default python3.9.6 libs are installed in /usr/lib/python3.9/site-packages/
pip-installed packages can be called with :
singularity exec -e /path/to/this/sif/image python3 -m pip list installed
or
singularity test /path/to/this/sif/image

Other custom GAD packages include GeneralTools, LabkeyTools, InterTools, VcfTools, CnvTools from v2.10.0 of the gadpipeline, modified to work with python3.9
(= from the 2.11.0_python3 branch)

%setup
SINGULARITY_ROOTFS=$APPTAINER_ROOTFS
mkdir ${SINGULARITY_ROOTFS}/data

%files
# import custom python packages from local machine
/home/valentinv/Documents/GitLab/gadpipeline/common/GeneralTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/LabkeyTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/InterTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/VcfTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/CnvTools.py /data/

%post
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

dnf install -y epel-release
dnf update -y libmodulemd
dnf update -y --exclude=filesystem
# filesystem packages updates poses problems by tempering with /proc, which is supposed to be owned by root, but is not in the .sif image

dnf remove -y python3 && dnf autoremove
dnf install -y python39

# install non-pip python packages
mv /data/GeneralTools.py /usr/lib/python3.9/site-packages/
mv /data/LabkeyTools.py /usr/lib/python3.9/site-packages/
# import of LabkeyTools.py in python3 causes error (TabError - indentation). Probably compatibility problem from python2
mv /data/InterTools.py /usr/lib/python3.9/site-packages/
mv /data/VcfTools.py /usr/lib/python3.9/site-packages/
mv /data/CnvTools.py /usr/lib/python3.9/site-packages/

# install python pip packages
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ labkey
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ numpy
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ matplotlib
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ pandas
# pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ plotly
# is causing an error due to plotly.plotly module being deprecated in python3.9. chart-studio package (with the chart_studio.plotly module) is to be used in replacement.
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ chart-studio
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ scipy
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ pyvcf
pip3.9 install --upgrade -t /usr/lib/python3.9/site-packages/ simplejson

#cleaning
rmdir /data/

%test
echo "python version :"
python3 -V
echo "listing installed pip packages :" 
python3 -m pip list 

%labels 
container_version v0.1
Creation date 2023-09-13
Contained_OS_version CentOS 8.5.211
Contained_python_version 3.9.6