Skip to content

Commit

Permalink
use cibuildwheel
Browse files Browse the repository at this point in the history
This uses cibuildwheel to build the wheels which will also allow
publishing ARM64 wheels.
  • Loading branch information
dlech committed Apr 8, 2023
1 parent aaf0a59 commit 20800a2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
71 changes: 33 additions & 38 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
name: publish
on:
name: Build and upload to PyPI

on:
push:
tags:
- v1.*
pull_request:
release:
types:
- published

jobs:
sdist:
runs-on: windows-2019
build_wheels:
name: Build wheels
runs-on: windows-2022

steps:
- uses: actions/checkout@v3
- run: python -m pip install build
- run: python -m build --sdist

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1

- uses: actions/upload-artifact@v3
with:
name: sdist_${{ github.run_id }}
path: dist/

bdist:
runs-on: windows-2019
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
architecture: ['x86', 'x64']
name: Python ${{ matrix.python-version }} ${{ matrix.architecture }} bdist
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- run: python -m pip install build
- name: Run python -m build --wheel
run: |
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" -DevCmdArguments '-arch=${{ matrix.architecture }}'
python -m build --wheel

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
name: bdist_${{ matrix.python-version }}_${{ matrix.architecture }}_${{ github.run_id }}
path: dist/
path: dist/*.tar.gz

publish:
needs: [sdist, bdist]
runs-on: ubuntu-20.04
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- run: |
mkdir -p dist
mv artifacts/{b,s}dist_*/* dist/
- uses: pypa/gh-action-pypi-publish@release/v1
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ lib64/
parts/
sdist/
var/
wheelhouse/
wheels/
pip-wheel-metadata/
share/python-wheels/
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[build-system]
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja"]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
skip = "pp*"
archs = "all"
build-verbosity = 1

0 comments on commit 20800a2

Please sign in to comment.