Using Jenkins for PyPI deployment. Travis stopped their generous open source support

This commit is contained in:
Matthias Koefferlein 2021-10-30 18:45:44 +02:00
parent 01d7600b87
commit ea1bf40a1e
3 changed files with 81 additions and 1 deletions

43
Jenkinsfile-pypi Normal file
View File

@ -0,0 +1,43 @@
@Library("platform") _
properties([disableConcurrentBuilds()])
// from shared library - uses tags to set the platform name
// (this is a pretty stupid way to set a parameter, but I don't
// know of a better way to parameterize a multibranch pipeline)
platform = pypi_platform()
py_version = pypi_py_version()
currentBuild.description = "PyPI deployment " + platform
docker_image = "jenkins-manylinux2014_x86_64-pypi"
target = platform + ".whl"
node("master") {
stage("Checkout sources") {
checkout scm
}
stage("Building target ${target}") {
sh("rm -rf wheelhouse ; mkdir -p wheelhouse")
withDockerContainer(image: docker_image, args: "-v " + pwd() + ":/io") {
sh("PY_VERSION=" + py_version + " /io/ci-scripts/docker/docker_build_jenkins.sh")
}
}
stage("Publish and test") {
// publish for release tags
if (BRANCH_NAME.startsWith('v')) {
sh("twine upload --skip-existing wheelhouse/klayout-*manylinux2014*.whl wheelhouse/*.zip")
}
}
}

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
if [[ -z $PY_VERSION ]]; then
echo '$PY_VERSION is not set'
exit 1
fi
echo PY_VERSION=$PY_VERSION
# Use single cores only so we do not overload the Jenkins host
export KLAYOUT_SETUP_MULTICORE=1
# Compile wheel and build source distribution
cd /io
"/opt/python/$PY_VERSION/bin/python" setup.py bdist_wheel -d /io/wheelhouse/ || exit 1
"/opt/python/$PY_VERSION/bin/python" setup.py sdist --formats=zip -d /io/wheelhouse || exit 1
# Bundle external shared libraries into the wheels via auditwheel
for whl in /io/wheelhouse/*linux_*.whl; do
auditwheel repair "$whl" -w /io/wheelhouse/ || exit 1
done
# Install packages and test
TEST_HOME=/io/testdata
"/opt/python/$PY_VERSION/bin/pip" install klayout --no-index -f /io/wheelhouse || exit 1
"/opt/python/$PY_VERSION/bin/python" $TEST_HOME/pymod/import_db.py || exit 1
"/opt/python/$PY_VERSION/bin/python" $TEST_HOME/pymod/import_rdb.py || exit 1
"/opt/python/$PY_VERSION/bin/python" $TEST_HOME/pymod/import_tl.py || exit 1
"/opt/python/$PY_VERSION/bin/python" $TEST_HOME/pymod/pya_tests.py || exit 1

View File

@ -65,7 +65,13 @@ from distutils.errors import CompileError
import distutils.command.build_ext
import setuptools.command.build_ext
import multiprocessing
N_cores = multiprocessing.cpu_count()
# for Jenkins we do not want to be greedy
multicore = os.getenv("KLAYOUT_SETUP_MULTICORE")
if multicore:
N_cores = int(multicore)
else:
N_cores = multiprocessing.cpu_count()
# monkey-patch for parallel compilation