Skip to content

Commit d5fd5db

Browse files
authored
build: use pyproject dependency groups and uv (#366)
* update ci * remove lockfile for now * remove frozen * nodev * whoops * add cache dep glob * add color * print compiled * try qt * refactor CI workflow: streamline environment variables and simplify install step * add name * nonconflict * pin pyside2 numpy * add early pydantic * fix syntax * fix syntax * fix syntax * rename step * drop pyside2 pin pydantic * fix codspeed * fix group * add no sync * try activate * use dot * try plain python * remove no sync * back to py3.10 * bump to py3.13 * update benchmarks job to use actions/setup-python@v5 and set HATCH_BUILD_HOOKS_ENABLE environment variable
1 parent 493f460 commit d5fd5db

File tree

10 files changed

+113
-145
lines changed

10 files changed

+113
-145
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

.devcontainer/add-notice.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

.devcontainer/noop.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 76 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,63 +20,90 @@ jobs:
2020
- run: pipx run check-manifest
2121

2222
test:
23-
name: Test
24-
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
25-
with:
26-
os: ${{ matrix.os }}
27-
python-version: ${{ matrix.python-version }}
28-
pip-post-installs: ${{ matrix.pydantic }}
29-
hatch-build-hooks-enable: ${{ matrix.compile }}
30-
pip-install-pre-release: ${{ github.event_name == 'schedule' }}
31-
coverage-upload: artifact
23+
name: Test ${{ matrix.qt }} ${{ matrix.os }} py${{ matrix.python-version }} mypyc-${{ matrix.compile }} ${{ matrix.pydantic }}
24+
runs-on: ${{ matrix.os }}
25+
env:
26+
HATCH_BUILD_HOOKS_ENABLE: ${{ matrix.compile }}
27+
UV_NO_SYNC: "1"
3228
strategy:
3329
fail-fast: false
3430
matrix:
35-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
31+
python-version: ["3.9", "3.11", "3.13"]
3632
os: [ubuntu-latest, macos-latest, windows-latest]
37-
compile: [true, false]
33+
compile: ["1", "0"]
34+
qt: [""]
35+
pydantic: [""]
3836
include:
37+
- os: ubuntu-latest
38+
python-version: "3.10"
39+
compile: "1"
3940
- os: ubuntu-latest
4041
python-version: "3.12"
41-
pydantic: "'pydantic<2'"
42+
compile: "1"
43+
# pydantic versions
44+
- os: ubuntu-latest
45+
python-version: "3.10"
46+
pydantic: "pydantic==1.10"
47+
compile: "1"
48+
- os: ubuntu-latest
49+
python-version: "3.9"
50+
pydantic: "pydantic==1.10"
51+
compile: "0"
52+
# qt stuff
53+
- os: macos-latest
54+
python-version: "3.10"
55+
qt: "PyQt5"
56+
compile: "0"
4257
- os: windows-latest
4358
python-version: "3.11"
44-
pydantic: "'pydantic<2'"
45-
exclude:
46-
# still working on ci test errors
47-
- os: windows-latest
48-
python-version: "3.12"
49-
- compile: true
59+
qt: "PySide6"
60+
compile: "1"
61+
- os: ubuntu-latest
5062
python-version: "3.13"
63+
qt: "PyQt6"
64+
compile: "1"
5165

52-
test-qt:
53-
name: Test Qt
54-
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
55-
with:
56-
os: ${{ matrix.os }}
57-
python-version: ${{ matrix.python-version }}
58-
qt: ${{ matrix.qt }}
59-
extras: "test,testqt"
60-
hatch-build-hooks-enable: ${{ matrix.compile }}
61-
pip-install-pre-release: ${{ github.event_name == 'schedule' }}
62-
coverage-upload: artifact
63-
strategy:
64-
fail-fast: false
65-
matrix:
66-
python-version: ["3.10"]
67-
os: [macos-latest, windows-latest]
68-
qt: [PyQt5, PyQt6, PySide6]
69-
compile: [true, false]
70-
include:
71-
- os: macos-13
72-
qt: "PySide2 'numpy<2'"
73-
- os: windows-latest
74-
python-version: "3.9"
75-
qt: "PySide2 'numpy<2'"
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: astral-sh/setup-uv@v6
69+
with:
70+
enable-cache: true
71+
python-version: ${{ matrix.python-version }}
72+
cache-dependency-glob: "**/pyproject.toml"
73+
74+
- name: Install the project
75+
run: |
76+
uv sync --no-dev --group test
77+
uv run python -c "import psygnal; print('compiled:', psygnal._compiled)"
78+
79+
- if: matrix.qt != ''
80+
uses: pyvista/setup-headless-display-action@v4
81+
with:
82+
qt: true
83+
84+
- if: matrix.qt != ''
85+
run: |
86+
uv sync --no-dev --group testqt
87+
uv pip install ${{ matrix.qt }}
88+
89+
- if: matrix.pydantic != ''
90+
name: downgrade pydantic
91+
run: uv pip install ${{ matrix.pydantic }}
92+
93+
- name: Test
94+
shell: bash
95+
run: uv run coverage run -p -m pytest -v
96+
97+
- name: Upload coverage
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: covreport-${{ matrix.os }}-py${{ matrix.python-version }}-mypyc${{ matrix.compile }}-${{ matrix.qt }}-${{ matrix.pydantic }}
101+
path: ./.coverage*
102+
include-hidden-files: true
76103

77104
upload_coverage:
78105
if: always()
79-
needs: [test, test-qt]
106+
needs: [test]
80107
uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2
81108
secrets: inherit
82109

@@ -109,17 +136,17 @@ jobs:
109136
- uses: actions/checkout@v4
110137
- uses: actions/setup-python@v5
111138
with:
112-
python-version: "3.10"
139+
python-version: "3.13"
113140

114-
- name: install
141+
- name: Install the project
115142
run: |
116-
python -m pip install -e .[test]
117-
python -m pip install pytest-codspeed
118-
python -c "import sys, psygnal; sys.exit(0 if psygnal._compiled else 1)"
143+
python -m pip install -U pip
144+
python -m pip install . --group test-codspeed
145+
python -c "import psygnal; print('compiled:', psygnal._compiled)"
119146
env:
120147
HATCH_BUILD_HOOKS_ENABLE: "1"
121148

122149
- name: Run benchmarks
123150
uses: CodSpeedHQ/action@v3
124151
with:
125-
run: pytest --codspeed -v --color=yes
152+
run: pytest --codspeed -v

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,6 @@ _version.py
113113
psygnal/_version.py
114114
.asv/
115115
wheelhouse/
116+
117+
# for now...
118+
uv.lock

.readthedocs.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ version: 2
55
build:
66
os: ubuntu-20.04
77
tools:
8-
python: "3.9"
8+
python: "3.12"
9+
jobs:
10+
post_install:
11+
- pip install uv
12+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs --link-mode=copy
913

1014
mkdocs:
1115
configuration: mkdocs.yml
1216
fail_on_warning: true
13-
14-
python:
15-
install:
16-
- method: pip
17-
path: .
18-
extra_requirements:
19-
- docs

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: build check clean benchmark-all benchmark-compare typetest
22

33
build:
4-
HATCH_BUILD_HOOKS_ENABLE=1 uv pip install -e . --force-reinstall
4+
HATCH_BUILD_HOOKS_ENABLE=1 uv sync --force-reinstall
55

66
check:
77
pre-commit run --all-files

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,22 @@ https://codspeed.io/pyapp-kit/psygnal
121121

122122
## Developers
123123

124+
### Setup
125+
126+
This project uses PEP 735 dependency groups.
127+
128+
After cloning, setup your env with `uv sync` or `pip install -e . --group dev`
129+
124130
### Compiling
125131

126132
While `psygnal` is a pure python package, it is compiled with mypyc to increase
127133
performance. To test the compiled version locally, you can run:
128134

129135
```bash
130-
make build
136+
HATCH_BUILD_HOOKS_ENABLE=1 uv sync --force-reinstall
131137
```
132138

133-
(which is just an alias for `HATCH_BUILD_HOOKS_ENABLE=1 pip install -e .`)
139+
(which is also available as `make build` if you have make installed)
134140

135141
### Debugging
136142

pyproject.toml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,10 @@ dependencies = [
3232
# extras
3333
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
3434
[project.optional-dependencies]
35-
docs = [
36-
"griffe==0.25.5",
37-
"mkdocs-autorefs==1.0.0",
38-
"mkdocs-material==8.5.10",
39-
"mkdocs-minify-plugin",
40-
"mkdocs==1.4.2",
41-
"mkdocstrings-python==0.8.3",
42-
"mkdocstrings==0.20.0",
43-
"mkdocs-spellcheck[all]",
44-
]
4535
proxy = ["wrapt"]
4636
pydantic = ["pydantic"]
37+
38+
[dependency-groups]
4739
test = [
4840
"dask[array]>=2024.0.0",
4941
"attrs",
@@ -56,19 +48,31 @@ test = [
5648
"msgspec",
5749
"toolz",
5850
]
59-
testqt = ["pytest-qt", "qtpy"]
60-
51+
testqt = [{ include-group = "test" }, "pytest-qt", "qtpy"]
52+
test-codspeed = [{ include-group = "test" }, "pytest-codspeed"]
53+
docs = [
54+
"griffe==0.25.5",
55+
"mkdocs-autorefs==1.0.0",
56+
"mkdocs-material==8.5.10",
57+
"mkdocs-minify-plugin",
58+
"mkdocs==1.4.2",
59+
"mkdocstrings-python==0.8.3",
60+
"mkdocstrings==0.20.0",
61+
"mkdocs-spellcheck[all]",
62+
]
6163
dev = [
62-
"psygnal[test, testqt]",
64+
{ include-group = "test" },
65+
{ include-group = "docs" },
6366
"PyQt6",
6467
"ipython",
6568
"mypy",
6669
"mypy_extensions",
6770
"pre-commit",
6871
"pytest-mypy-plugins",
69-
"rich",
7072
"ruff",
7173
"typing-extensions",
74+
"rich>=14.0.0",
75+
"pdbpp; sys_platform != 'win32'",
7276
]
7377

7478
[project.urls]
@@ -152,7 +156,7 @@ select = [
152156
"C4", # flake8-comprehensions
153157
"B", # flake8-bugbear
154158
"A001", # flake8-builtins
155-
"TC", # flake8-typecheck
159+
"TC", # flake8-typecheck
156160
"TID", # flake8-tidy-imports
157161
"RUF", # ruff-specific rules
158162
]
@@ -172,6 +176,7 @@ docstring-code-format = true
172176
[tool.pytest.ini_options]
173177
minversion = "6.0"
174178
testpaths = ["tests"]
179+
addopts = ["--color=yes"]
175180
filterwarnings = [
176181
"error",
177182
"ignore:The distutils package is deprecated:DeprecationWarning:",

0 commit comments

Comments
 (0)