Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package C extension to wheel #225

Merged
merged 10 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 93 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,85 @@ jobs:
- name: Run tox
run: tox

deploy:
runs-on: ubuntu-latest
needs: test
if: endsWith(github.ref, '/master')
permissions:
id-token: write
contents: write
make-wheels:
name: Make ${{ matrix.os }} ${{ matrix.cibw_arch }} wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
cibw_arch: ["native"]
cibw_build: ["cp38-* cp39-* cp310-* cp311-* cp312-*"]
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: "Checkout repo"
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install poetry
run: pip install poetry

- name: "Build wheels"
uses: pypa/[email protected]
with:
python-version: 3.8
output-dir: dist
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_BUILD_FRONTEND: pip
CIBW_BEFORE_ALL_LINUX: yum install -y libffi-devel clang make
CIBW_BUILD_VERBOSITY: 1

- name: Install build dependencies
run: |
pip install poetry
- name: "Upload wheel as artifact"
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.cibw_arch }}-wheel
path: "./**/dist/*.whl"

make-sdist:
name: Make source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install poetry
run: pip install poetry

- run: poetry build -f sdist

- uses: actions/upload-artifact@v4
with:
name: artifact-source-dist
path: "./**/dist/*.tar.gz"


test-publish:
name: Test PyPI Publishing
runs-on: ubuntu-latest
needs: [test, make-wheels, make-sdist]
# only run jobs if the feature branch is the base repo (not in a fork)
# TODO fails PRs from forks due to: "missing or insufficient OIDC token permissions,
# the ACTIONS_ID_TOKEN_REQUEST_TOKEN environment variable was unset"
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
id-token: write
contents: write
steps:
- name: Fetch version
id: fetch_version
run: echo "version_nr=$(poetry version -s)" >> $GITHUB_OUTPUT

- name: Build a binary wheel and a source tarball
# Note: poetry build required to support CLI script entrypoint in pyproject.toml?!
- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Copy artifacts to dist/ folder
run: |
poetry build --no-interaction
find . -name 'artifact-*' -exec unzip '{}' \;
mkdir -p dist/
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
find . -name '*.whl' -exec mv '{}' dist/ \;
ls -lR dist/

- name: Test PyPI Publishing
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -80,6 +132,30 @@ jobs:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

publish:
runs-on: ubuntu-latest
# Note: only runs, when test publishing worked
needs: [test, make-wheels, make-sdist, test-publish]
if: endsWith(github.ref, '/master')
permissions:
id-token: write
contents: write
steps:
- name: Fetch version
id: fetch_version
run: echo "version_nr=$(poetry version -s)" >> $GITHUB_OUTPUT

- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Copy artifacts to dist/ folder
run: |
find . -name 'artifact-*' -exec unzip '{}' \;
mkdir -p dist/
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
find . -name '*.whl' -exec mv '{}' dist/ \;
ls -lR dist/

- name: Create GitHub Release
id: create_gh_release
uses: ncipollo/release-action@v1
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========


6.5.1 (2024-06-14)
------------------

* added support for cibuildwheel: publish wheels including the native C extension. GHA CI/CD pipeline creates sdist (no binaries inside) and a bunch of binary wheels with a prebuilt clang-pip extension for each python version. Thanks to @theirix



6.5.0 (2024-03-14)
------------------

Expand Down
1 change: 1 addition & 0 deletions docs/3_about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Thanks to:

- `Adam <https://github.com/adamchainz>`__ for adding organisational features to the project and for helping me with publishing and testing routines.
- `ringsaturn <https://github.com/ringsaturn>`__ for valuable feedback, sponsoring this project, creating the ``tzfpy`` package and adding the ``pytz`` compatibility extra
- `theirix <https://github.com/theirix>`__ for adding support for cibuildwheel
- `snowman2 <https://github.com/snowman2>`__ for creating the conda-forge recipe.
- `synapticarbors <https://github.com/synapticarbors>`__ for fixing Numba import with py27.
- `zedrdave <https://github.com/zedrdave>`__ for valuable feedback.
Expand Down
Loading