Skip to content

Commit ab4c198

Browse files
build(python): migrate to pyproject.toml and uv tooling
1 parent c038529 commit ab4c198

6 files changed

Lines changed: 219 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ concurrency:
1212
group: "${{ github.workflow }}-${{ github.ref }}"
1313
cancel-in-progress: true
1414

15+
env:
16+
PYTHON_VERSION: '3.14'
17+
1518
jobs:
1619
setup_release:
1720
name: Setup Release
@@ -173,21 +176,18 @@ jobs:
173176
id: setup-python
174177
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
175178
with:
176-
python-version: '3.14'
179+
python-version: ${{ env.PYTHON_VERSION }}
177180

178-
- name: Python Path
179-
id: python-path
180-
run: |
181-
if [ "${{ runner.os }}" = "Windows" ]; then
182-
# replace backslashes with double backslashes
183-
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
184-
else
185-
python_path=${{ steps.setup-python.outputs.python-path }}
186-
fi
181+
- name: Setup uv
182+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
183+
with:
184+
enable-cache: true
187185

188-
# step output
189-
echo "python-path=${python_path}"
190-
echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}"
186+
- name: Sync Python tools
187+
env:
188+
MSYS2_PATH_TYPE: inherit
189+
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
190+
run: uv sync --locked
191191

192192
- name: Configure
193193
run: |
@@ -271,9 +271,10 @@ jobs:
271271
always() &&
272272
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
273273
working-directory: build
274+
env:
275+
MSYS2_PATH_TYPE: inherit
274276
run: |
275-
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
276-
${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \
277+
uv run --locked gcovr . -r ../src \
277278
--exclude-noncode-lines \
278279
--exclude-throw-branches \
279280
--exclude-unreachable-branches \

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
# VSCode IDE
3838
.vscode/
3939

40+
# Python
41+
.venv/
42+
4043
# build directories
4144
build/
4245
cmake-*/

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ cmake -G Ninja -B build -S .
8484
ninja -C build
8585
```
8686

87+
## Python Tooling
88+
89+
Install [uv](https://docs.astral.sh/uv/) to sync and run the Python tools:
90+
91+
```bash
92+
uv sync
93+
uv run python scripts/update_clang_format.py
94+
```
95+
8796
## Demo
8897

8998
Execute the `tray_example` application:

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "tray"
3+
version = "0.0.0"
4+
description = "A cross-platform system tray library"
5+
readme = "README.md"
6+
requires-python = ">=3.14"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = [
11+
"clang-format==21.*",
12+
"gcovr==8.6",
13+
]

scripts/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)