Skip to content

Add publishing to PyPI - #180

Open
behrmann wants to merge 3 commits into
systemd:mainfrom
behrmann:pypi
Open

behrmann wants to merge 3 commits into
systemd:mainfrom
behrmann:pypi

Conversation

@behrmann

Copy link
Copy Markdown
Member

The publishing part is so far commented out, because trusted publishing needs to be set up, which it (probably) isn't yet, and I also wanted to see whether the build jobs actually work.

- actions/checkout -> v7
- github/codeql-action -> v4
This adds a new workflow pypi-publish that builds wheels using the
pypa/cibuildwheel GitHub action and a Python source distribution (sdist) via
the build module (run via pipx, which is included in the runner images) and
uploads them to PyPI via pypa/gh-action-pypi-publish using the trused
publishing mechanism.
- name: Store built wheels
uses: actions/upload-artifact@v7
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job index is probably not very descriptive (and reordering or deprecating Python versions will make your brain freeze)... maybe be explicit here?

Suggested change
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
name: cibw-wheels-${{ matrix.os }}-cp${{ matrix.python }}-${{ matrix.manylinux_platform }}

Comment on lines +9 to +38
strategy:
matrix:
include:
- os: ubuntu-latest
python: 39
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 310
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 311
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 312
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 313
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 314
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 314t
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 315
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 315t
manylinux_platform: manylinux_x86_64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write this way smaller, as a cross product... in theory you could also not include os and manylinux_platform and hardcode them... but I think this makes new versions of Python simpler to add.

Suggested change
strategy:
matrix:
include:
- os: ubuntu-latest
python: 39
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 310
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 311
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 312
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 313
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 314
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 314t
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 315
manylinux_platform: manylinux_x86_64
- os: ubuntu-latest
python: 315t
manylinux_platform: manylinux_x86_64
strategy:
matrix:
os: [ubuntu-latest]
manylinux_platform: [manylinux_x86_64]
python: [39, 310, 311, 312, 313, 314, 314t, 315, 315t]

@@ -0,0 +1,104 @@
name: Build and publish Python package to TestPyPI

on: [push]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that you are trying to test uploading into the test PyPI, but in general, that doesn't really test much other than that a) you can build a wheel b) The test API is working, and c) this wheel is accepted by PyPI. Other than "this wheel is accepted" everything else can (and should?) be just tested in CI/CD.

consider also add a on: publish that will upload github published artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants