Skip to content

Commit 9de73b9

Browse files
committed
Fix MANIFEST, declare license properly.
Also publish pre-built wheels. Drop -march=native flag.
1 parent 1cbe1fd commit 9de73b9

File tree

6 files changed

+181
-53
lines changed

6 files changed

+181
-53
lines changed

.github/workflows/build_and_test.yml

Lines changed: 135 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,145 @@ 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+
with:
108+
registry: ghcr.io
109+
username: ${{ github.repository_owner }}
110+
password: ${{ secrets.GITHUB_TOKEN }}
111+
112+
- name: Set dynamic environment
113+
id: set-env
114+
run: |
115+
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
116+
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
117+
sort -u | grep -v unknown | paste -sd ','`"
118+
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
119+
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
120+
BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}"
121+
echo "Platforms: ${PLATFORMS}"
122+
echo "Build Image: ${BUILD_IMAGE}"
123+
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
124+
echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV
125+
126+
- name: Build Docker image
127+
uses: docker/build-push-action@v6
128+
env:
129+
CACHE_SPEC: "type=registry,ref=${{ env.BUILD_IMAGE }}-buildcache"
130+
with:
131+
context: .
132+
file: ./docker/Dockerfile.python_wheels
133+
build-args: |
134+
BASE_IMAGE=${{ env.BASE_IMAGE }}
135+
PY_VER=${{ env.PY_VER }}
136+
platforms: ${{ env.PLATFORMS }}
137+
push: false
138+
outputs: type=local,dest=dist_out
139+
cache-from: ${{ env.CACHE_SPEC }}
140+
cache-to: ${{ env.CACHE_SPEC }},mode=max
141+
142+
- name: Collect Wheels
143+
run: |
144+
mkdir dist
145+
mv `find dist_out -type f -name \*.whl` dist
146+
rm -r dist_out
147+
148+
- name: Upload built wheels
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: dist-${{ env.PY_VER }}
152+
path: dist
153+
154+
publish_pypi:
155+
needs: build_bin_wheels
81156
runs-on: ubuntu-latest
82157
environment:
83158
name: pypi
84159
url: https://pypi.org/p/asyncproxy
85160
permissions:
86161
id-token: write
162+
actions: read
163+
contents: read
87164
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
165+
- uses: actions/checkout@v4
166+
167+
- name: Download all wheel artifacts
168+
uses: actions/download-artifact@v4
169+
with:
170+
path: dist
171+
pattern: dist-*
172+
merge-multiple: true
173+
174+
- name: Set up Python
175+
uses: actions/setup-python@v5
176+
with:
177+
python-version: '3.x'
178+
179+
- name: Install dependencies
180+
run: |
181+
python -m pip install --upgrade pip
182+
pip install --upgrade build setuptools wheel
183+
184+
- name: build
185+
run: python setup.py build sdist
186+
187+
- name: Show context tree
188+
run: ls -R dist
189+
190+
- name: Publish package distributions to PyPI
191+
if: github.event_name == 'release' && github.event.action == 'created'
192+
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
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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
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 ()
3128
if False:
3229
extra_compile_args.extend(debug_opts)
3330
extra_link_args.extend(debug_opts)
@@ -63,8 +60,8 @@ def get_ex_mod():
6360
'packages':['asyncproxy',],
6461
'package_dir':{'asyncproxy':'python'},
6562
'ext_modules': get_ex_mod(),
63+
'license': 'BSD-2-Clause',
6664
'classifiers': [
67-
'License :: OSI Approved :: BSD License',
6865
'Operating System :: POSIX',
6966
'Programming Language :: C',
7067
'Programming Language :: Python'

0 commit comments

Comments
 (0)