changeset 52244:4b9cf9924cd7 stable

wheels: update the Linux wheels make target This reuse the script extracted in the previous changeset and now build the wheels with the same image and code as the CI.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 12 Nov 2024 02:22:40 +0100
parents 4d825ad10840
children d57d1606049c
files contrib/packaging/Makefile contrib/packaging/build-linux-wheels.sh
diffstat 2 files changed, 37 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/packaging/Makefile	Wed Nov 13 04:20:54 2024 +0100
+++ b/contrib/packaging/Makefile	Tue Nov 12 02:22:40 2024 +0100
@@ -129,7 +129,7 @@
 
 .PHONY: linux-wheels-x86_64
 linux-wheels-x86_64:
-	docker run -e "HGTEST_JOBS=$(shell nproc)" --rm -ti -v `pwd`/../..:/src quay.io/pypa/manylinux1_x86_64 /src/contrib/packaging/build-linux-wheels.sh
+	docker run --rm -ti -v `pwd`/../..:/src registry.heptapod.net/mercurial/ci-images/core-wheel-x86_64-c:v3.0 /src/contrib/packaging/build-linux-wheels.sh
 
 .PHONY: linux-wheels-i686
 linux-wheels-i686:
--- a/contrib/packaging/build-linux-wheels.sh	Wed Nov 13 04:20:54 2024 +0100
+++ b/contrib/packaging/build-linux-wheels.sh	Tue Nov 12 02:22:40 2024 +0100
@@ -1,34 +1,44 @@
 #!/bin/bash
-# This file is directly inspired by
-# https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh
+
+# Intended to run within docker using image:
+#
+#  registry.heptapod.net/mercurial/ci-images/core-wheel-x86_64-c:v3.0
+#
+# we might want to factor most of this with the associated mercurial-core CI
+# definition. (i.e. move this script into a place where the CI can directly call it for its purpose)
+
 set -e -x
 
-PYTHON_TARGETS=$(ls -d /opt/python/cp27*/bin)
+PYTHON_TARGETS="cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313"
+
+export MERCURIAL_SETUP_FORCE_TRANSLATIONS=1
 
-# Create an user for the tests
-useradd hgbuilder
+# We need to copy the repository to ensure:
+# (1) we don't wrongly write roots files in the repository (or any other wrong
+#     users)
+# (2) we don't reuse pre-compiled extension built outside for manylinux and
+#     therefor not compatible.
+cp -r /src/ /tmp/src/
+cd /tmp/src/
+hg purge --all --no-confirm
 
-# Bypass uid/gid problems
-cp -R /src /io && chown -R hgbuilder:hgbuilder /io
+export HGRCPATH=/tmp/build-config.rc
+cat << EOF > $HGRCPATH
+[trusted]
+users=*
+groups=*
+EOF
 
-# Compile wheels for Python 2.X
-for PYBIN in $PYTHON_TARGETS; do
-    "${PYBIN}/pip" wheel /io/ -w wheelhouse/
+for py in $PYTHON_TARGETS; do
+    echo 'build wheel for' $py
+    # cleanup any previous wheel
+    tmp_wd="/tmp/wheels/$py/repaired"
+    rm -rf $tmp_wd
+    mkdir -p $tmp_wd
+    # build a new wheel
+    contrib/build-one-linux-wheel.sh $py $tmp_wd
+    # fix the owner back to the repository owner
+    chown `stat /src/ -c %u:%g` $tmp_wd/*.whl
+    mv $tmp_wd/*.whl /src/dist
 done
 
-# Bundle external shared libraries into the wheels with
-# auditwheel (https://github.com/pypa/auditwheel) repair.
-# It also fix the ABI tag on the wheel making it pip installable.
-for whl in wheelhouse/*.whl; do
-    auditwheel repair "$whl" -w /src/wheelhouse/
-done
-
-# Install packages and run the tests for all Python versions
-cd /io/tests/
-
-for PYBIN in $PYTHON_TARGETS; do
-    # Install mercurial wheel as root
-    "${PYBIN}/pip" install mercurial --no-index -f /src/wheelhouse
-    # But run tests as hgbuilder user (non-root)
-    su hgbuilder -c "\"${PYBIN}/python\" /io/tests/run-tests.py --with-hg=\"${PYBIN}/hg\" --blacklist=/io/contrib/packaging/linux-wheel-centos5-blacklist"
-done