Skip to content

Commit 00aaa16

Browse files
authored
ci: replace PDM with UV (#73)
Replacing PDM with UV improves the integration with tox. It is no longer needed to install pyenv, download Python versions, etc. Instead `uv` takes care of these details. All that is needed is ```BASH uv tool install tox --with tox-uv tox ``` to run compatibility tests with multiple Python versions.
1 parent 0f84a1e commit 00aaa16

11 files changed

Lines changed: 1126 additions & 1753 deletions

File tree

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
---
2-
name: publish on TestPyPI
2+
#
3+
# documentation:
4+
# - https://docs.pypi.org/trusted-publishers/
5+
# - https://github.com/astral-sh/trusted-publishing-examples/blob/main/.github/workflows/release.yml
6+
#
7+
name: publish package on TestPyPI
38

49
on:
5-
release:
6-
types: [published]
7-
workflow_dispatch:
10+
push:
11+
tags:
12+
- v*
813

914
jobs:
1015
build-and-upload:
1116
name: build package and upload to PyPI
1217
runs-on: ubuntu-latest
13-
environment: publish-to-pypi-test
18+
environment:
19+
name: publish-to-pypi-test
1420
permissions:
1521
contents: read
1622
id-token: write
1723
steps:
18-
- uses: actions/checkout@v4
19-
- uses: pdm-project/setup-pdm@v4
20-
- name: Publish package distributions to PyPI
21-
run: pdm publish --repository testpypi
22-
# publish to PyPI (generic)
23-
# - name: Publish package distributions to PyPI
24-
# uses: pypa/gh-action-pypi-publish@release/v1
25-
# publish to Test-PyPI (generic)
26-
# - name: Publish package distributions to TestPyPI
27-
# uses: pypa/gh-action-pypi-publish@release/v1
28-
# with:
29-
# repository-url: https://test.pypi.org/legacy/
24+
- name: Checkout repository
25+
uses: actions/checkout@v6
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v7
28+
- name: Build package
29+
run: uv build
30+
# Check that basic features work and we didn't miss to include crucial files
31+
# - name: Smoke test (wheel)
32+
# run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
33+
# - name: Smoke test (source distribution)
34+
# run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
35+
- name: Publish package
36+
run: uv publish

.github/workflows/validate-code.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: checkout repository
33-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3434
- name: identify changed files
3535
uses: tj-actions/changed-files@v46
3636
id: changed-files
@@ -41,32 +41,27 @@ jobs:
4141
contrib:
4242
- examples/**.py
4343
- test/**.py
44-
- name: configure Python (using PDM)
45-
uses: pdm-project/setup-pdm@v4
46-
with:
47-
python-version-file: pyproject.toml
48-
- name: install dependencies
49-
run: |
50-
pdm install
44+
- name: install uv
45+
uses: astral-sh/setup-uv@v7
5146
- name: lint code (flake8)
5247
env:
5348
LIBRARY_FILES: ${{ steps.changed-files.outputs.library_all_changed_files }}
5449
CONTRIB_FILES: ${{ steps.changed-files.outputs.contrib_all_changed_files }}
5550
run: |
5651
if [[ -n $LIBRARY_FILES ]] || [[ -n $CONTRIB_FILES ]] ; then
5752
# the GitHub editor is 127 chars wide
58-
pdm run flake8 --max-line-length=127 --show-source --statistics $LIBRARY_FILES $CONTRIB_FILES
53+
uv run flake8 --max-line-length=127 --show-source --statistics $LIBRARY_FILES $CONTRIB_FILES
5954
fi
6055
- name: lint code (mypy)
6156
env:
6257
CONTRIB_FILES: ${{ steps.changed-files.outputs.contrib_all_changed_files }}
6358
run: |
6459
# since this is a namespace package we must instruct mypy to scan
6560
# the code as a namespace package; it won't work if we scan files
66-
pdm run mypy -p feeph.i2c
61+
uv run mypy -p feeph.i2c
6762
# example scripts and tests can be scanned as files
6863
if [[ -n $CONTRIB_FILES ]] ; then
69-
pdm run mypy $CONTRIB_FILES
64+
uv run mypy $CONTRIB_FILES
7065
fi
7166
test:
7267
name: perform unit tests
@@ -81,15 +76,19 @@ jobs:
8176
- "3.12"
8277
steps:
8378
- name: checkout repository
84-
uses: actions/checkout@v4
79+
uses: actions/checkout@v6
8580
- name: configure Python ${{ matrix.python-version }}
8681
uses: actions/setup-python@v5
8782
with:
8883
python-version: ${{ matrix.python-version }}
84+
- name: install uv
85+
uses: astral-sh/setup-uv@v7
8986
- name: install dependencies
87+
with:
88+
python-version: ${{ matrix.python-version }}
9089
run: |
90+
uv export --format=requirements.txt --all-extras --dev > requirements.txt
9191
pip install -r requirements.txt
92-
pip install pytest pytest-md pytest-emoji
9392
# https://github.com/marketplace/actions/run-pytest
9493
- name: perform unit tests (Python ${{ matrix.python-version }})
9594
env:

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.9

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json)](https://github.com/copier-org/copier)
44
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
55
[![Coverage Status](https://coveralls.io/repos/github/feeph/libi2c-python/badge.svg)](https://coveralls.io/github/feeph/libi2c-python)
6-
[![pdm-managed](https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json)](https://pdm-project.org)
7-
[![tox](https://img.shields.io/badge/tox-ab79d2)](https://tox.wiki/)
6+
[![uvm-managed](https://img.shields.io/badge/packaging-uv-ab79d2)](https://docs.astral.sh/uv/)
7+
[![tox](https://img.shields.io/badge/testing-tox-ab79d2)](https://tox.wiki/)
88

99
abstraction layer for the I²C bus (incl. simulation for testing)
1010

0 commit comments

Comments
 (0)