Skip to content

Feat/build multiple wheels #20

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

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
267ad4a
use cibuildwheel to build multiple wheels
Oisin-M Apr 24, 2025
768a048
switch to always upload to pypi or pypi test
Oisin-M Apr 24, 2025
36a17ce
update default py versions for cd-pypi.yml
Oisin-M Apr 24, 2025
45f586d
fix json parsing
Oisin-M Apr 24, 2025
66f35b2
bugfix str to list
Oisin-M Apr 24, 2025
d52882f
attempt bugfix
Oisin-M Apr 25, 2025
a224d14
remove dot in pyversion def args
Oisin-M Apr 25, 2025
bc188c9
pip install in CIBW_BEFORE_BUILD
Oisin-M Apr 25, 2025
bef32fa
pip install cibuildwheel before running wheel build
Oisin-M Apr 25, 2025
d423719
install rust
Oisin-M Apr 25, 2025
79db8d2
fix artifact upload wheels
Oisin-M Apr 25, 2025
feba855
attempt bugfix artifact
Oisin-M Apr 25, 2025
a13af8c
bugfix typo
Oisin-M Apr 25, 2025
1c3df9b
attempt bugfix rust install
Oisin-M Apr 25, 2025
974ef0d
bugfix rust install
Oisin-M Apr 25, 2025
b62e0e7
improve rust install
Oisin-M Apr 25, 2025
3ecae0e
debug rust install
Oisin-M Apr 25, 2025
61b2926
debug rust install v2
Oisin-M Apr 25, 2025
d6e00f9
simplify cd
Oisin-M Apr 25, 2025
3f45df5
remove skip in cd action
Oisin-M Apr 25, 2025
74358a7
upload directly to pypi without artifact
Oisin-M Apr 25, 2025
5c77591
allow running on windows
Oisin-M Apr 25, 2025
8a5bfe5
maintain previous functionality
Oisin-M Apr 25, 2025
06ab1ab
bugfix strategy
Oisin-M Apr 25, 2025
4810856
make sure matrix has non missing default value even if never used
Oisin-M Apr 25, 2025
3a4e07a
add default versions for os and pyversion
Oisin-M Apr 25, 2025
7f5cf9c
try escaping quotes
Oisin-M Apr 25, 2025
4851258
attempt to use format to bypass yaml issues
Oisin-M Apr 25, 2025
324688c
try with custom default value
Oisin-M Apr 25, 2025
225eb20
escape quotes
Oisin-M Apr 25, 2025
e00c4d5
try to use an invalid def value
Oisin-M Apr 25, 2025
2d9ce98
invalid as def arg
Oisin-M Apr 25, 2025
eb9d140
default as empty string
Oisin-M Apr 28, 2025
219a349
drop curly braces
Oisin-M Apr 28, 2025
20435ec
improve naming
Oisin-M Apr 28, 2025
85452ab
fix renaming
Oisin-M Apr 28, 2025
9db103e
split binwheel and purepython cd-pypi
Oisin-M May 13, 2025
4af7c3a
add way to set arbitrary env vars as input
Oisin-M May 13, 2025
bd79561
bugfix twine install
Oisin-M May 13, 2025
594fca7
remove artifact
Oisin-M May 13, 2025
ed0e0f6
install twine
Oisin-M May 13, 2025
b3e7d0f
fix typo in buildargs
Oisin-M May 13, 2025
8c2fb5f
rename to cd-pypi-binwheel
Oisin-M May 14, 2025
d1a6cab
add checks before building and uploading
Oisin-M May 14, 2025
b50cca4
typo
Oisin-M May 14, 2025
8a89b1b
debug
Oisin-M May 14, 2025
4e45b0c
set testpypi as env var
Oisin-M May 14, 2025
b297c65
remove debug print
Oisin-M May 14, 2025
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
97 changes: 97 additions & 0 deletions .github/workflows/cd-pypi-binwheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
name: cd-pypi

on:
workflow_call:
inputs:
testpypi:
description: Whether to upload to testpypi instead of pypi.
Requires secrets.PYPI_TEST_API_TOKEN to be defined.
type: boolean
required: false
default: false
working-directory:
description: Working directory to build Python package (for monorepos).
Defaults to root directory.
type: string
required: false
default: "./"
platforms:
description: For not pure python project, the platforms to build for e.g. "['ubuntu-latest','macos-latest','windows-latest']"
required: false
type: string
default: ''
pyversions:
description: For not pure python project, the Python versions to build for e.g. "['38','39','310','311','312','313']"
required: false
type: string
default: ''
env_vars:
description: A way to set env variables
type: string
required: false
default: ''


jobs:
deploy:
if: inputs.platforms != '' && inputs.pyversions != ''
strategy:
matrix:
platform: ${{ fromJson(inputs.platforms) }}
python: ${{ fromJson(inputs.pyversions) }}
runs-on: ${{ matrix.platform }}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- name: Set env variables from input
if: inputs.env_vars != ''
run: |
for key in $(echo '${{ inputs.env_vars }}' | jq -r 'keys[]'); do
value=$(echo '${{ inputs.env_vars }}' | jq -r ".\"$key\"")
echo "$key=$value" >> $GITHUB_ENV
done
shell: bash

- uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine setuptools wheel cibuildwheel

- name: Build wheels
run: |
cibuildwheel --output-dir dist
env:
CIBW_BUILD: "cp${{ matrix.python }}-*"
CIBW_BUILD_VERBOSITY: 1

- name: Upload to PyPI
if: ${{ !inputs.testpypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine check dist/*.whl
twine upload dist/*.whl

- name: Upload to test-PyPI
if: ${{ inputs.testpypi }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: |
twine check dist/*.whl
# HINT: if your upload fails here due to "unsupported local version",
# put `local_scheme = "no-local-version"` pyproject.toml's
# [tools.setuptools_scm]
twine upload --repository testpypi --verbose dist/*.whl
25 changes: 23 additions & 2 deletions .github/workflows/cd-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ on:
type: string
required: false
default: "./"
buildargs:
description: Args to pass in to build as `python -m build {buildargs}`
e.g. '--sdist' for just source distribution
type: string
required: false
default: ''
env_vars:
description: A way to set env variables
type: string
required: false
default: ''


jobs:
deploy:
Expand All @@ -25,6 +37,15 @@ jobs:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- name: Set env variables from input
if: inputs.env_vars != ''
run: |
for key in $(echo '${{ inputs.env_vars }}' | jq -r 'keys[]'); do
value=$(echo '${{ inputs.env_vars }}' | jq -r ".\"$key\"")
echo "$key=$value" >> $GITHUB_ENV
done
shell: bash

- uses: actions/checkout@v4
with:
fetch-depth: "0"
Expand Down Expand Up @@ -81,7 +102,7 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m build
python -m build ${{ inputs.buildargs }}
twine check dist/*
twine upload dist/*

Expand All @@ -91,7 +112,7 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: |
python -m build
python -m build ${{ inputs.buildargs }}
twine check dist/*
# HINT: if your upload fails here due to "unsupported local version",
# put `local_scheme = "no-local-version"` pyproject.toml's
Expand Down