Skip to content

Build Python wheels for all the platforms #447

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

Merged
merged 1 commit into from
Feb 11, 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
49 changes: 42 additions & 7 deletions .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,15 @@ jobs:
allow-empty: true

build:
name: Build source
name: Build source on ${{ matrix.platform }}
needs: [run-tox, coverage]
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.12"]
steps:
- name: Checkout source at ${{ matrix.platform }}
uses: actions/checkout@v4
Expand All @@ -124,7 +122,6 @@ jobs:
python -m pip install -r requirements/build.txt
python -m build --outdir dist-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Compiles Python modules to C extensions with Mypyc
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12' }}
env:
MYPYC_ENABLE: 1
run: |
Expand All @@ -135,15 +132,46 @@ jobs:
- name: Tar build and wheel distributions files
run: |
tar -cvf dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar dist-${{ matrix.platform }}-${{ matrix.python-version }}
tar -cvf mypyc-dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar mypyc-dist-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Upload build and wheel distributions files
uses: actions/upload-artifact@v4
with:
name: pre-release-build-${{ matrix.platform }}-${{ matrix.python-version }}
path: dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar
path: |
dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar
mypyc-dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar

build-wheels:
name: Build wheels on ${{ matrix.platform }}
needs: [run-tox, coverage]
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest
python-version: ["3.12"]
steps:
- name: Checkout source at ${{ matrix.platform }}
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cbuild dependencies
run: python -m pip install -r requirements/cbuild.txt
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: pre-release-cibw-wheels-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl

publish-testpypi:
name: Publish to TestPyPI
needs: build
needs: [build, build-wheels]
runs-on: ${{ matrix.platform }}
permissions:
contents: write
Expand All @@ -164,10 +192,17 @@ jobs:
uses: actions/download-artifact@v4
with:
name: pre-release-build-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Download cibw wheels distributions files
uses: actions/download-artifact@v4
with:
path: pre-release-cibw-wheels
pattern: pre-release-cibw-wheels-*
merge-multiple: true
- name: Build source and wheel distributions to version ${{ github.ref_name }}
run: |
python -m pip install -r requirements/build.txt
tar -xvf dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar
mv pre-release-cibw-wheels/* dist-${{ matrix.platform }}-${{ matrix.python-version }}/
twine check --strict dist-${{ matrix.platform }}-${{ matrix.python-version }}/*
- name: Publish distribution to TestPyPI
uses: pypa/[email protected]
Expand Down
81 changes: 76 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,67 @@ permissions:
contents: write

jobs:
build-n-publish:
name: Build and publish to PyPI
build:
name: Build source on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
python-version: ["3.12"]
steps:
- name: Checkout source at ${{ matrix.platform }}
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build source and wheel distributions
run: |
python -m pip install -r requirements/build.txt
python -m build --outdir dist-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Tar build and wheel distributions files
run: |
tar -cvf dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar dist-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Upload build and wheel distributions files
uses: actions/upload-artifact@v4
with:
name: release-build-${{ matrix.platform }}-${{ matrix.python-version }}
path: |
dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar

build-wheels:
name: Build wheels on ${{ matrix.platform }}
needs: [run-tox, coverage]
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest
python-version: ["3.12"]
steps:
- name: Checkout source at ${{ matrix.platform }}
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cbuild dependencies
run: python -m pip install -r requirements/cbuild.txt
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: release-cibw-wheels-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl

publish-n-release:
name: Publish to PyPI and generate GitHub release ${{ github.ref_name }}
needs: [build, build-wheels]
runs-on: ${{ matrix.platform }}
permissions:
contents: write
Expand All @@ -27,16 +86,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download build and wheel distributions files
uses: actions/download-artifact@v4
with:
name: release-build-${{ matrix.platform }}-${{ matrix.python-version }}
- name: Download cibw wheels distributions files
uses: actions/download-artifact@v4
with:
path: release-cibw-wheels
pattern: release-cibw-wheels-*
merge-multiple: true
- name: Build source and wheel distributions to version ${{ github.ref_name }}
run: |
python -m pip install -r requirements/build.txt
python -m build
twine check --strict dist/*
tar -xvf dist-${{ matrix.platform }}-${{ matrix.python-version }}.tar
mv release-cibw-wheels/* dist-${{ matrix.platform }}-${{ matrix.python-version }}/
twine check --strict dist-${{ matrix.platform }}-${{ matrix.python-version }}/*
- name: Publish distribution to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist-${{ matrix.platform }}-${{ matrix.python-version }}/
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
Expand All @@ -49,4 +120,4 @@ jobs:
LICENSE
AUTHORS
README.md
dist/*
dist-${{ matrix.platform }}-${{ matrix.python-version }}/*
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["src/buildtools"]

[project]
name = "Flask-JSONRPC"
version = "3.0.1a0"
version = "3.0.1a1"
description = "Adds JSONRPC support to Flask."
readme = {file = "README.md", content-type = "text/markdown"}
license = {file = "LICENSE"}
Expand Down Expand Up @@ -59,6 +59,20 @@ namespaces = false
[tool.distutils.bdist_wheel]
universal = true

[tool.cibuildwheel]
before-all = "uname -a"
build-verbosity = 1
skip = [
"cp3{8,9,10}-*",
"*-manylinux_i686",
"*-musllinux_i686",
"*-win32",
"pp*",
]

[tool.cibuildwheel.environment]
MYPYC_ENABLE = "1"

[tool.ruff]
src = ["src"]
fix = true
Expand Down
4 changes: 4 additions & 0 deletions requirements/cbuild.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
-r build.txt

# Tools
# ------------------------------------------------------------------------------
cibuildwheel==2.16.5

# Mypyc
# ------------------------------------------------------------------------------
mypy[mypyc]==1.8.0 # https://github.com/python/mypy
Expand Down