Build musllinux wheels

Change-Id: I2fba40d0746e29b68b7504ec7c4ccfc085759f8f
This commit is contained in:
Tim Burke 2024-09-17 12:24:19 -07:00
parent 8967b70b85
commit 29f1add6ba
8 changed files with 34 additions and 11 deletions

View File

@ -6,6 +6,8 @@ ARG TARGET="x86_64"
FROM quay.io/pypa/manylinux2010_x86_64:2021-02-06-3d322a5 AS x86_64
FROM quay.io/pypa/manylinux2014_aarch64:2021-05-01-a10bece AS aarch64
FROM quay.io/pypa/musllinux_1_1_x86_64:2021-09-18-f12faf3 AS musl_x86_64
FROM quay.io/pypa/musllinux_1_1_aarch64:2021-09-18-f12faf3 AS musl_aarch64
FROM ${TARGET}
MAINTAINER OpenStack Swift
@ -24,11 +26,13 @@ RUN mkdir /opt/src /output
# Fix up mirrorlist issues
RUN rm -f /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo && \
RUN if [ -e /etc/yum.repos.d ]; then \
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo && \
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo && \
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo ; \
fi
RUN yum install -y zlib-devel
RUN if [ -n "$(type -p yum)" ]; then yum install -y zlib-devel ; fi
# Update auditwheel so it can improve our tag to manylinux1 automatically
# Not *too far*, though, since we've got the old base image
RUN /opt/_internal/tools/bin/pip install -U 'auditwheel<5.2'

View File

@ -170,12 +170,14 @@ def relocate_libs(tmp, so_suffix):
# These guys all stand on their own, so don't need the rpath update
inject(locate_library('nullcode'))
inject(locate_library('Xorcode'))
inject(locate_library('erasurecode_rs_vand'))
builtin_rs_vand = inject(locate_library('erasurecode_rs_vand'))
maybe_add_needed(relocated_libec, os.path.basename(builtin_rs_vand))
# Nobody actually links against this, but we want it anyway if available
isal = locate_library('isal', missing_ok=True)
if isal:
inject(isal)
relocated_isal = inject(isal)
maybe_add_needed(relocated_libec, os.path.basename(relocated_isal))
def update_rpath(lib, rpath_suffix=''):
@ -190,6 +192,13 @@ def update_rpath(lib, rpath_suffix=''):
'patchelf', '--set-rpath', '$ORIGIN' + rpath_suffix, lib])
def maybe_add_needed(lib, needed):
if sys.platform == 'linux' and platform.libc_ver()[0] != 'glibc':
# We need to do this for musl; it doesn't seem to respect RUNPATH
# for dynamic loading, just dynamic linking
subprocess.check_call(['patchelf', '--add-needed', needed, lib])
def inject_lib(
whl_dir,
src_lib,

View File

@ -1,4 +0,0 @@
- name: Build image
command: "docker build --build-arg TARGET={{ wheel_target }} . --tag {{ tag }}"
args:
chdir: "{{ zuul.project.src_dir }}"

View File

@ -0,0 +1,9 @@
- name: Build image (glibc)
command: "docker build --build-arg TARGET={{ wheel_target }} . --tag {{ tag }}"
args:
chdir: "{{ zuul.project.src_dir }}"
- name: Build image (musl)
command: "docker build --build-arg TARGET=musl_{{ wheel_target }} . --tag {{ tag }}-musl"
args:
chdir: "{{ zuul.project.src_dir }}"

View File

@ -1,2 +1,3 @@
tag: pyeclib-build-wheel-latest
wheel_python_version: cp35-cp35m
musl: False

View File

@ -3,4 +3,4 @@
docker run --rm
--env PYTHON_VERSION={{ wheel_python_version }}
--volume {{ ansible_user_dir }}/artifacts:/output:Z
{{ tag }}
{{ tag }}{{ "-musl" if musl else "" }}

View File

@ -1,6 +1,6 @@
- hosts: all
roles:
- build-pyeclib-image
- build-pyeclib-images
- role: build-pyeclib-wheel
wheel_python_version: cp27-cp27m
@ -12,3 +12,7 @@
- role: build-pyeclib-wheel
wheel_python_version: cp35-cp35m
- role: build-pyeclib-wheel
wheel_python_version: cp36-cp36m
musl: True