mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 10:06:01 +01:00
WIP: Docker containers and bash scripts to produce manylinux wheels for different platforms
This commit is contained in:
parent
dcfe1da870
commit
c63d420c7f
45
docker/README
Normal file
45
docker/README
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
First, make sure to place the source code distribution (suffixed with .tar.gz) of the TREXIO Python API in this directory.
|
||||||
|
|
||||||
|
TODO: the scripts have to be adapted for an arbitrary version of TREXIO and Python !
|
||||||
|
|
||||||
|
Outside Docker image:
|
||||||
|
|
||||||
|
# Build containers with hdf5 inside:
|
||||||
|
|
||||||
|
# for manylinux2014_x86_64
|
||||||
|
sudo docker build -t hdf5_1_12_on_2014_x86_64 . -f Dockerfile_2014_x86_64
|
||||||
|
|
||||||
|
# for manylinux_2_24_x86_64
|
||||||
|
sudo docker build -t hdf5_1_12_on_2_24_x86_64 . -f Dockerfile_2_24_x86_64
|
||||||
|
|
||||||
|
# (create an image using HDF5 containers, see https://github.com/h5py/hdf5-manylinux)
|
||||||
|
# -t hdf5_1_12_on_${PLATFORM} builds an image with a custom name (hdf5_1_12_1)
|
||||||
|
|
||||||
|
# Run one of the produced containers in the interactive mode
|
||||||
|
|
||||||
|
# for manylinux2014_x86_64
|
||||||
|
sudo docker run --rm -it -e PLAT=manylinux2014_x86_64 -v `pwd`:/tmp hdf5_1_12_on_2014_x86_64 /bin/bash
|
||||||
|
|
||||||
|
# for manylinux_2_24_x86_64
|
||||||
|
sudo docker run --rm -it -e PLAT=manylinux_2_24_x86_64 -v `pwd`:/tmp hdf5_1_12_on_2_24_x86_64 /bin/bash
|
||||||
|
|
||||||
|
#(PLAT specifies the base platform tag for manilinux)
|
||||||
|
#-i (run docker container interactively)
|
||||||
|
#-t f8e4232fa208 (run an image using ID if the image is not named)
|
||||||
|
#/bin/bash (a binary to run inside a container environment)
|
||||||
|
|
||||||
|
In the Docker image:
|
||||||
|
|
||||||
|
cd tmp && ./build_manylinux_wheels_py_36_37_38.sh
|
||||||
|
# (creates virtual environments, installs things with pip, produces conventional wheels and repairs them with auditwheel)
|
||||||
|
|
||||||
|
# auditwheel repair trexio-0.1.0/dist/trexio-0.1.0-cp37-cp37m-linux_x86_64.whl
|
||||||
|
# (repairs wheel and produces manylinux one)
|
||||||
|
|
||||||
|
After Docker container execution:
|
||||||
|
|
||||||
|
# the produced manylinux wheels are in trexio-0.1.0/wheelhouse directory
|
||||||
|
|
||||||
|
# ALTERNATIVELY: one can copy the produced manylinux wheel from the container back to the host system
|
||||||
|
sudo docker cp $CONTAINER_ID:/tmp/trexio-0.1.0/wheelhouse/MANYLINUX_NAME.whl directory-on-the-user-machine/
|
||||||
|
|
165
docker/build_manylinux_wheels_py_36_37_38_39.sh
Executable file
165
docker/build_manylinux_wheels_py_36_37_38_39.sh
Executable file
@ -0,0 +1,165 @@
|
|||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export H5_LDFLAGS=-L/usr/local/lib
|
||||||
|
export H5_CFLAGS=-I/usr/local/include
|
||||||
|
|
||||||
|
# install emacs for Debian
|
||||||
|
|
||||||
|
#apt-get update
|
||||||
|
#apt install software-properties-common -y
|
||||||
|
#apt-get install wget -y
|
||||||
|
|
||||||
|
#wget -q http://emacs.ganneff.de/apt.key -O- | apt-key add
|
||||||
|
|
||||||
|
#add-apt-repository "deb http://emacs.ganneff.de/ stretch main"
|
||||||
|
#apt-get update
|
||||||
|
#apt-get install emacs-snapshot -y
|
||||||
|
#update-alternatives --config emacsclient
|
||||||
|
|
||||||
|
# ===============================
|
||||||
|
|
||||||
|
# install TREXIO in the container from the GitHub repo clone
|
||||||
|
|
||||||
|
#apt-get install git -y
|
||||||
|
|
||||||
|
#git clone https://github.com/TREX-CoE/trexio.git
|
||||||
|
#cd trexio
|
||||||
|
#git checkout swig-python
|
||||||
|
|
||||||
|
#./autogen.sh
|
||||||
|
#TREXIO_DEVEL=1 ./configure --enable-silent-rules
|
||||||
|
#make
|
||||||
|
#make check
|
||||||
|
|
||||||
|
# ===============================
|
||||||
|
|
||||||
|
# alternatively: build wheel directly from developer-provided .tar.gz of TREXIO (generated with `python setup.py sdist`)
|
||||||
|
# note: trexio-VERSION.tar.gz has to be in the root directory of the host machine
|
||||||
|
|
||||||
|
# unzip and enter the folder with TREXIO Python API
|
||||||
|
gzip -cd /tmp/trexio-0.1.0.tar.gz | tar xvf -
|
||||||
|
cd trexio-0.1.0
|
||||||
|
|
||||||
|
# create and activate a virtual environment based on CPython version 3.6
|
||||||
|
/opt/python/cp36-cp36m/bin/python3 -m venv --clear trexio-manylinux-py36
|
||||||
|
source trexio-manylinux-py36/bin/activate
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# upgrade pip, otherwise it complains that manylinux wheel is "...not supported wheel on this platform"
|
||||||
|
pip install --upgrade pip
|
||||||
|
# install dependencies needed to build manylinux wheel
|
||||||
|
pip install --upgrade setuptools wheel auditwheel numpy
|
||||||
|
|
||||||
|
# set an environment variable needed to locate numpy header files
|
||||||
|
source tools/set_NUMPY_INCLUDEDIR.sh
|
||||||
|
|
||||||
|
# produce conventional (non-manylinux) wheel
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
# use auditwheel from PyPA to repair all wheels and make them manylinux-compatible
|
||||||
|
auditwheel repair dist/trexio-0.1.0-cp36-cp36m-*.whl
|
||||||
|
|
||||||
|
# install the produced manylinux wheel in the virtual environment
|
||||||
|
python3 -m pip install wheelhouse/trexio-0.1.0-cp36-cp36m-manylinux*.whl
|
||||||
|
|
||||||
|
# run test script
|
||||||
|
cd test && python3 test_api.py && cd ..
|
||||||
|
|
||||||
|
# cleaning
|
||||||
|
rm -rf -- dist/ build/ trexio.egg-info/
|
||||||
|
|
||||||
|
# deactivate the current environment
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
# create and activate a virtual environment based on CPython version 3.7
|
||||||
|
/opt/python/cp37-cp37m/bin/python3 -m venv --clear trexio-manylinux-py37
|
||||||
|
source trexio-manylinux-py37/bin/activate
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# upgrade pip, otherwise it complains that manylinux wheel is "...not supported wheel on this platform"
|
||||||
|
pip install --upgrade pip
|
||||||
|
# install dependencies needed to build manylinux wheel
|
||||||
|
pip install --upgrade setuptools wheel auditwheel numpy
|
||||||
|
|
||||||
|
# set an environment variable needed to locate numpy header files
|
||||||
|
source tools/set_NUMPY_INCLUDEDIR.sh
|
||||||
|
|
||||||
|
# produce conventional (non-manylinux) wheel
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
# use auditwheel from PyPA to repair all wheels and make them manylinux-compatible
|
||||||
|
auditwheel repair dist/trexio-0.1.0-cp37-cp37m-*.whl
|
||||||
|
|
||||||
|
# install the produced manylinux wheel in the virtual environment
|
||||||
|
python3 -m pip install wheelhouse/trexio-0.1.0-cp37-cp37m-manylinux*.whl
|
||||||
|
|
||||||
|
# run test script
|
||||||
|
cd test && python3 test_api.py && cd ..
|
||||||
|
|
||||||
|
# cleaning
|
||||||
|
rm -rf -- dist/ build/ trexio.egg-info/
|
||||||
|
|
||||||
|
# deactivate the current environment
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
# create and activate a virtual environment based on CPython version 3.8
|
||||||
|
# NOTE: starting from CPython 3.8 there is no need to add m in the abi-tag, e.g. use cp38-cp38 instead of cp38-cp38m
|
||||||
|
/opt/python/cp38-cp38/bin/python3 -m venv --clear trexio-manylinux-py38
|
||||||
|
source trexio-manylinux-py38/bin/activate
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# upgrade pip, otherwise it complains that manylinux wheel is "...not supported wheel on this platform"
|
||||||
|
pip install --upgrade pip
|
||||||
|
# install dependencies needed to build manylinux wheel
|
||||||
|
pip3 install --upgrade setuptools wheel auditwheel numpy
|
||||||
|
|
||||||
|
# set an environment variable needed to locate numpy header files
|
||||||
|
source tools/set_NUMPY_INCLUDEDIR.sh
|
||||||
|
|
||||||
|
# produce conventional (non-manylinux) wheel
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
# use auditwheel from PyPA to repair all wheels and make them manylinux-compatible
|
||||||
|
auditwheel repair dist/trexio-0.1.0-cp38-cp38-*.whl
|
||||||
|
|
||||||
|
# install the produced manylinux wheel in the virtual environment
|
||||||
|
python3 -m pip install wheelhouse/trexio-0.1.0-cp38-cp38-manylinux*.whl
|
||||||
|
|
||||||
|
# run test script
|
||||||
|
cd test && python3 test_api.py && cd ..
|
||||||
|
|
||||||
|
# cleaning
|
||||||
|
rm -rf -- dist/ build/ trexio.egg-info/
|
||||||
|
|
||||||
|
# deactivate the current environment
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
# create and activate a virtual environment based on CPython version 3.8
|
||||||
|
/opt/python/cp39-cp39/bin/python3 -m venv --clear trexio-manylinux-py39
|
||||||
|
source trexio-manylinux-py39/bin/activate
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# upgrade pip, otherwise it complains that manylinux wheel is "...not supported wheel on this platform"
|
||||||
|
pip install --upgrade pip
|
||||||
|
# install dependencies needed to build manylinux wheel
|
||||||
|
pip3 install --upgrade setuptools wheel auditwheel numpy
|
||||||
|
|
||||||
|
# produce conventional (non-manylinux) wheel
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
# use auditwheel from PyPA to repair all wheels and make them manylinux-compatible
|
||||||
|
auditwheel repair dist/trexio-0.1.0-cp39-cp39-*.whl
|
||||||
|
|
||||||
|
# install the produced manylinux wheel in the virtual environment
|
||||||
|
python3 -m pip install wheelhouse/trexio-0.1.0-cp39-cp39-manylinux*.whl
|
||||||
|
|
||||||
|
# run test script
|
||||||
|
cd test && python3 test_api.py && cd ..
|
||||||
|
|
||||||
|
# cleaning
|
||||||
|
rm -rf -- dist/ build/ trexio.egg-info/
|
||||||
|
|
||||||
|
# deactivate the current environment
|
||||||
|
deactivate
|
||||||
|
|
Loading…
Reference in New Issue
Block a user