Skip to content
Open
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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
"3.12",
"3.13",
"3.14",
"3.15",
]
exclude:
- os: "ubuntu-22.04"
Expand All @@ -40,10 +41,10 @@ jobs:
name: Python ${{ matrix.python }} on ${{ matrix.os }}
steps:
- name: Repository checkout
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Configure Python ${{ matrix.python }}
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: +security-extended,security-and-quality
Expand All @@ -48,7 +48,7 @@ jobs:
python -m pip install -U --break-system-packages pip build

- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v4

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
109 changes: 109 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build and publish Python package to TestPyPI
on:
pull_request:
push:
branches:
- main
release:
types: [published]

jobs:
build_wheels:
name: Build wheel cp${{ matrix.python }}-${{ matrix.manylinux_platform }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
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
Comment on lines +14 to +43

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.


steps:
- name: Checkout python-systemd for wheel build
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: Set SOURCE_DATE_EPOCH from source commit
run: |
printf "SOURCE_DATE_EPOCH=%s\n" "$(git log -1 --pretty=%ct)" >>"$GITHUB_ENV"

- name: Build wheels
uses: pypa/cibuildwheel@8c2dcd2e96041a619f5ff03c9638d7941e2553a4 # v4.3.3
env:
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
with:
only: cp${{ matrix.python }}-${{ matrix.manylinux_platform }}

- name: Store built wheels
uses: actions/upload-artifact@v7
with:
name: cibw-wheels-${{ matrix.os }}-cp${{ matrix.python }}-${{ matrix.manylinux_platform }}
path: ./wheelhouse/*.whl

make_sdist:
name: Make sdist
runs-on: ubuntu-latest
steps:
- name: Checkout python-systemd for source distribution build
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: install libsystemd
run: |
sudo apt-get --update -y install libsystemd-dev

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

- name: Store built sdist
uses: actions/upload-artifact@v7
with:
name: cibw-sdist
path: ./dist/*.tar.gz

upload_all:
needs: [build_wheels, make_sdist]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v8
with:
pattern: cibw-*
path: dist
merge-multiple: true

# - name: Publish package distributions to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Logging",
"Topic :: System :: Systems Administration",
Expand Down Expand Up @@ -64,3 +65,10 @@ exclude_lines = [
[tool.pytest.ini_options]
addopts = "--doctest-modules --doctest-glob=*.rst --ignore=setup.py"
norecursedirs = ".git build"

[tool.cibuildwheel]
build-verbosity = 1
manylinux-x86_64-image = "manylinux_2_34"
manylinux-i686-image = "manylinux_2_34"
before-all = "dnf -y install systemd-devel || apt-get --update -y install libsystemd-dev"
environment-pass = ["SOURCE_DATE_EPOCH"]
Loading