Skip to content

Commit 6b58415

Browse files
committed
Fix MANIFEST, declare license properly.
Also publish pre-built wheels. Drop -march=native flag, add -march=x86-64 on 'linux-x86_64' to workaround pypa/manylinux#1725.
1 parent 1cbe1fd commit 6b58415

File tree

6 files changed

+189
-53
lines changed

6 files changed

+189
-53
lines changed

.github/workflows/build_and_test.yml

Lines changed: 137 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ permissions:
2424
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2525
jobs:
2626
build_and_test_python:
27-
continue-on-error: true
2827
strategy:
28+
fail-fast: false
2929
matrix:
3030
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
3131
compiler: ['gcc', 'clang']
@@ -48,57 +48,147 @@ jobs:
4848

4949
# Steps represent a sequence of tasks that will be executed as part of the job
5050
steps:
51-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
52-
- uses: actions/checkout@v4
53-
54-
- name: Set up Python ${{ matrix.python-version }}
55-
uses: actions/setup-python@v5
56-
with:
57-
python-version: ${{ matrix.python-version }}
58-
59-
- name: Install dependencies
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install setuptools wheel
63-
shell: bash
64-
65-
- name: build
66-
run: CC=${COMPILER} LDSHARED="${COMPILER} -shared" python setup.py build sdist
67-
shell: bash
68-
69-
- name: install
70-
run: pip install dist/*.gz
71-
shell: bash
72-
73-
- name: test
74-
run: |
75-
python -m unittest discover -v -s tests -p '*.py'
76-
shell: bash
77-
78-
publish_wheels:
51+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
59+
- name: Install dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install --upgrade build setuptools wheel
63+
shell: bash
64+
65+
- name: build
66+
run: CC=${COMPILER} LDSHARED="${COMPILER} -shared" python setup.py build sdist
67+
shell: bash
68+
69+
- name: install
70+
run: pip install dist/*.gz
71+
shell: bash
72+
73+
- name: test
74+
run: |
75+
python -m unittest discover -v -s tests -p '*.py'
76+
shell: bash
77+
78+
build_bin_wheels:
7979
needs: build_and_test_python
80-
if: github.event_name == 'release' && github.event.action == 'created'
80+
runs-on: ubuntu-latest
81+
permissions:
82+
packages: write
83+
env:
84+
PY_VER: ${{ matrix.python-version }}
85+
BASE_IMAGE: quay.io/pypa/manylinux_2_28:latest
86+
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
python-version: ['3.8', '3.9', '3.11', '3.12']
91+
steps:
92+
- name: Set up Python ${{ env.PY_VER }}
93+
uses: actions/setup-python@v5
94+
with:
95+
python-version: ${{ env.PY_VER }}
96+
97+
- uses: actions/checkout@v4
98+
99+
- name: Set up QEMU
100+
uses: docker/setup-qemu-action@v3
101+
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
105+
- name: Login to GitHub Container Registry
106+
uses: docker/login-action@v3
107+
if: github.event_name != 'pull_request'
108+
with:
109+
registry: ghcr.io
110+
username: ${{ github.repository_owner }}
111+
password: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Set dynamic environment
114+
id: set-env
115+
run: |
116+
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
117+
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
118+
sort -u | grep -v unknown | paste -sd ','`"
119+
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
120+
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
121+
BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}"
122+
test "${{ github.event_name }}" != 'pull_request' && \
123+
CACHE_SPEC="type=registry,ref=${BUILD_IMAGE}-buildcache" || \
124+
CACHE_SPEC="gha"
125+
echo "Platforms: ${PLATFORMS}"
126+
echo "Build Image: ${BUILD_IMAGE}"
127+
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
128+
echo "CACHE_SPEC=${CACHE_SPEC}" >> $GITHUB_ENV
129+
130+
- name: Build Binary Wheels
131+
uses: docker/build-push-action@v6
132+
with:
133+
context: .
134+
file: ./docker/Dockerfile.python_wheels
135+
build-args: |
136+
BASE_IMAGE=${{ env.BASE_IMAGE }}
137+
PY_VER=${{ env.PY_VER }}
138+
platforms: ${{ env.PLATFORMS }}
139+
push: false
140+
outputs: type=local,dest=dist_out
141+
cache-from: ${{ env.CACHE_SPEC }}
142+
cache-to: ${{ env.CACHE_SPEC }},mode=max
143+
144+
- name: Collect Wheels
145+
run: |
146+
mkdir dist
147+
mv `find dist_out -type f -name \*.whl` dist
148+
rm -r dist_out
149+
150+
- name: Upload built wheels
151+
uses: actions/upload-artifact@v4
152+
with:
153+
name: dist-${{ env.PY_VER }}
154+
path: dist
155+
156+
publish_pypi:
157+
needs: build_bin_wheels
81158
runs-on: ubuntu-latest
82159
environment:
83160
name: pypi
84161
url: https://pypi.org/p/asyncproxy
85162
permissions:
86163
id-token: write
164+
actions: read
165+
contents: read
87166
steps:
88-
- uses: actions/checkout@v4
89-
90-
- name: Set up Python
91-
uses: actions/setup-python@v5
92-
with:
93-
python-version: '3.12'
94-
95-
- name: Install dependencies
96-
run: |
97-
python -m pip install --upgrade pip
98-
pip install setuptools wheel
99-
100-
- name: build
101-
run: python setup.py build sdist
102-
103-
- name: Publish package distributions to PyPI
104-
uses: pypa/gh-action-pypi-publish@release/v1
167+
- uses: actions/checkout@v4
168+
169+
- name: Download all wheel artifacts
170+
uses: actions/download-artifact@v4
171+
with:
172+
path: dist
173+
pattern: dist-*
174+
merge-multiple: true
175+
176+
- name: Set up Python
177+
uses: actions/setup-python@v5
178+
with:
179+
python-version: '3.x'
180+
181+
- name: Install dependencies
182+
run: |
183+
python -m pip install --upgrade pip
184+
pip install --upgrade build setuptools wheel
185+
186+
- name: build
187+
run: python setup.py build sdist
188+
189+
- name: Show context tree
190+
run: ls -R dist
191+
192+
- name: Publish package distributions to PyPI
193+
if: github.event_name == 'release' && github.event.action == 'created'
194+
uses: pypa/gh-action-pypi-publish@release/v1

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include src/Symbol.map src/asp_iostats.h src/asp_sock.So src/asp_sock.c src/asp_sock.h src/asyncproxy.So src/asyncproxy.c src/asyncproxy.h
1+
include src/Symbol.map src/asp_iostats.h src/asp_sock.c src/asp_sock.h src/asyncproxy.c src/asyncproxy.h
22
include README.md

docker/Dockerfile.python_wheels

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
3+
ARG BASE_IMAGE="quay.io/pypa/manylinux_2_28:latest"
4+
FROM --platform=$TARGETPLATFORM $BASE_IMAGE AS build
5+
LABEL maintainer="Maksym Sobolyev <[email protected]>"
6+
7+
USER root
8+
9+
WORKDIR /src
10+
11+
ARG TARGETPLATFORM
12+
ARG PY_VER
13+
RUN --mount=type=bind,source=scripts/build,target=scripts/build \
14+
sh -x scripts/build/install_depends_yum.sh
15+
RUN --mount=type=bind,source=scripts/build,target=scripts/build \
16+
sh -x scripts/build/install_depends_wheels.sh
17+
18+
COPY --exclude=.git --exclude=.github --exclude=docker --exclude=dist \
19+
--exclude=scripts . .
20+
21+
RUN python${PY_VER} -m build --wheel
22+
RUN auditwheel repair dist/*.whl --wheel-dir dist_out
23+
24+
FROM scratch AS export
25+
COPY --from=build /src/dist_out /dist
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
python${PY_VER} -m ensurepip --upgrade
6+
python${PY_VER} -m pip install --upgrade pip
7+
python${PY_VER} -m pip install --upgrade build setuptools wheel auditwheel

scripts/build/install_depends_yum.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ "${PY_VER}" = "3.9" -o "${PY_VER}" = "3.8" ]
6+
then
7+
PY_VER="3${PY_VER#3.}"
8+
dnf module enable python${PY_VER} -y
9+
fi
10+
11+
dnf install -y redhat-lsb-core python${PY_VER} python${PY_VER}-devel

setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424

2525
debug_opts = ('-g3', '-O0')
2626
nodebug_opts = ('-DNO_DEBUG',)
27-
if not is_mac and not is_win:
28-
nodebug_opts += ('-march=native', '-O3')
29-
else:
30-
nodebug_opts += ('-O3',) if not is_win else ()
27+
nodebug_opts += ('-O3',) if not is_win else ()
28+
29+
if get_platform() == 'linux-x86_64':
30+
# This is to disable x86-64-v2, see
31+
# https://github.com/pypa/manylinux/issues/1725
32+
extra_compile_args.append('-march=x86-64')
33+
3134
if False:
3235
extra_compile_args.extend(debug_opts)
3336
extra_link_args.extend(debug_opts)
@@ -63,8 +66,8 @@ def get_ex_mod():
6366
'packages':['asyncproxy',],
6467
'package_dir':{'asyncproxy':'python'},
6568
'ext_modules': get_ex_mod(),
69+
'license': 'BSD-2-Clause',
6670
'classifiers': [
67-
'License :: OSI Approved :: BSD License',
6871
'Operating System :: POSIX',
6972
'Programming Language :: C',
7073
'Programming Language :: Python'

0 commit comments

Comments
 (0)