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
@behrmann
behrmann force-pushed the pypi branch 2 times, most recently from 7071779 to 0e1949f Compare October 27, 2026 14:30
Comment thread .github/workflows/pypi-publish.yml Outdated
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]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's indeed shorter, but I unrolled the loop, because I think we might not do the full product in all cases, e.g. when adding aarch64. Alternatively it could make sense to target different versions of manylinux for different Python releases. That's still something to look into.

Comment thread .github/workflows/pypi-publish.yml Outdated
@@ -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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently I'm just testing whether the build actually works and is useful. :) I just downloaded a wheel built for 3.14 and ran it on my Arch machine and it didn't segfault right away, so success, I guess? I still need to find out, though, why it ran in my fork but apparently not here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, well, obviously because I forgot the "on pullrequest".

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.
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