changed: build opm-common python extension using cmake

only use setup.py to generate wheels. adjust pypi packaging
accordingly
This commit is contained in:
Arne Morten Kvarving
2023-01-06 15:59:34 +01:00
parent 85fc610c85
commit 5d854d1d6d
11 changed files with 101 additions and 301 deletions

View File

@@ -4,53 +4,38 @@
# docker run -e PLAT=manylinux2014_x86_64 -it quay.io/pypa/manylinux2014_x86_64
VERSION_TAG=${1:-""}
BUILD_JOBS=4
export PYTHON36=/opt/python/cp36-cp36m/bin/python
export PYTHON37=/opt/python/cp37-cp37m/bin/python
export PYTHON38=/opt/python/cp38-cp38/bin/python
export PYTHON39=/opt/python/cp39-cp39/bin/python
export PYTHON310=/opt/python/cp310-cp310/bin/python
declare -A python_versions
python_versions[cp36-cp36m]=/opt/python/cp36-cp36m/bin/python
python_versions[cp37-cp37m]=/opt/python/cp37-cp37m/bin/python
python_versions[cp38-cp38]=/opt/python/cp38-cp38/bin/python
python_versions[cp39-cp39]=/opt/python/cp39-cp39/bin/python
python_versions[cp310-cp310]=/opt/python/cp310-cp310/bin/python
/bin/bash /tmp/opm-common/python/setup-docker-image.sh
source /tmp/opm-common/python/setup-docker-image.sh
cd /tmp/opm-common
mkdir -p /tmp/opm-common/wheelhouse
# Delete the folder if it already exists
if [ -d build ]; then
rm -rf build
fi
for tag in ${!python_versions[@]}
do
# Delete the folder if it already exists
if [ -d $tag ]; then
rm -rf $tag
fi
mkdir $tag && pushd $tag
cmake3 -DPYTHON_EXECUTABLE=${python_versions[$tag]} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 -DWITH_NATIVE=0 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
mkdir build && cd build
cmake3 -DPYTHON_EXECUTABLE=${PYTHON36} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} -DBUILD_TESTING=0 ..
# make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step
make -j4
./setup-package.sh
${PYTHON36} -m auditwheel repair python/dist/*cp36*.whl
# Run setup-package.sh three more times (Python 3.7, 3.8 and 3.9)
cmake3 -DPYTHON_EXECUTABLE=${PYTHON37} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
./setup-package.sh
${PYTHON37} -m auditwheel repair python/dist/*cp37*.whl
cmake3 -DPYTHON_EXECUTABLE=${PYTHON38} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
./setup-package.sh
${PYTHON38} -m auditwheel repair python/dist/*cp38*.whl
cmake3 -DPYTHON_EXECUTABLE=${PYTHON39} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
./setup-package.sh
${PYTHON39} -m auditwheel repair python/dist/*cp39*.whl
cmake3 -DPYTHON_EXECUTABLE=${PYTHON310} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
./setup-package.sh
${PYTHON310} -m auditwheel repair python/dist/*cp310*.whl
# make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step
make opmcommon_python -j${BUILD_JOBS}
cd python
${python_versions[$tag]} setup.py sdist bdist_wheel --plat-name manylinux2014_x86_64 --python-tag $tag
${python_versions[$tag]} -m auditwheel repair dist/*$tag*.whl
cp dist/*$tag*.whl /tmp/opm-common/wheelhouse
popd
done
# Example of upload
# /usr/bin/python3 -m twine upload --repository testpypi wheelhouse/*