Skip to content

Commit e48fc4b

Browse files
authored
build: use uv for project management (#700)
* chore: update uv and pre-commit * add lockfile * fix docs * fix workflow * remove old tests * remove host extra * napari-src * drop macos 13 * change min * switch up * try import mode * update lockfile * update fetch depth * back to windows * pin to wheels for windows pyqt5 * remove unsafe fixes from pyproject, add back to pre-commit * remove lock * repin qt * update deploy too
1 parent 1084189 commit e48fc4b

File tree

15 files changed

+194
-186
lines changed

15 files changed

+194
-186
lines changed

.github/workflows/deploy_docs.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@ jobs:
1515
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18-
- uses: actions/setup-python@v5
18+
- uses: astral-sh/setup-uv@v6
1919
with:
20-
python-version: "3.x"
21-
- run: |
22-
python -m pip install --upgrade pip
23-
python -m pip install -e .[docs]
20+
enable-cache: true
2421

2522
- name: Deploy docs to GitHub Pages
2623
if: github.event_name == 'push'
27-
run: mkdocs gh-deploy --strict --force
24+
run: uv run --group docs mkdocs gh-deploy --strict --force
2825

2926
- name: Test that docs build without error
3027
if: github.event_name == 'pull_request'
31-
run: mkdocs build --strict
28+
run: uv run --group docs mkdocs build --strict

.github/workflows/test_and_deploy.yml

Lines changed: 84 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,79 +15,93 @@ on:
1515

1616
jobs:
1717
test:
18-
name: Test
19-
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
20-
with:
21-
os: ${{ matrix.os }}
22-
python-version: ${{ matrix.python-version }}
23-
qt: ${{ matrix.qt }}
24-
pip-install-pre-release: ${{ github.event_name == 'schedule' }}
25-
coverage-upload: artifact
18+
name: ${{ matrix.os }} (${{ matrix.python-version }}) ${{ matrix.add-group || '' }} ${{ matrix.resolution || ''}}
19+
runs-on: ${{ matrix.os }}
20+
env:
21+
UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }}
22+
UV_NO_SYNC: 1
2623
strategy:
2724
fail-fast: false
2825
matrix:
2926
python-version: ["3.10", "3.11"]
3027
os: [ubuntu-latest, macos-latest, windows-latest]
31-
qt: [pyqt6, pyside6]
28+
add-group: [pyqt6, pyside6]
3229
include:
30+
- os: windows-latest
31+
python-version: "3.11"
32+
resolution: "lowest-direct"
33+
add-group: pyside6
3334
- python-version: "3.9"
3435
os: ubuntu-latest
35-
qt: pyqt5
36+
add-group: pyqt5
3637
- python-version: "3.9"
3738
os: ubuntu-latest
38-
qt: pyside2
39-
- python-version: "3.9"
40-
os: macos-13
41-
qt: pyside2
42-
- python-version: "3.9"
43-
os: macos-13
44-
qt: pyqt5
45-
- python-version: "3.9"
39+
add-group: pyside2
40+
- python-version: "3.11"
4641
os: windows-latest
47-
qt: pyqt5
42+
add-group: pyqt5
4843
- python-version: "3.10"
4944
os: ubuntu-latest
50-
qt: pyside2
45+
add-group: pyside2
5146
- python-version: "3.12"
5247
os: ubuntu-latest
53-
qt: pyqt6
48+
add-group: pyqt6
5449
- python-version: "3.12"
5550
os: ubuntu-latest
56-
qt: pyside6
51+
add-group: pyside6
5752
- python-version: "3.13"
5853
os: ubuntu-latest
59-
qt: pyside6
54+
add-group: pyside6
6055
- python-version: "3.13"
6156
os: windows-latest
62-
qt: pyqt6
57+
add-group: pyqt6
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
fetch-tags: true
6363

64-
test-min-reqs:
65-
name: Test min reqs
66-
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
67-
with:
68-
os: ubuntu-latest
69-
python-version: ${{ matrix.python-version }}
70-
qt: pyqt5
71-
pip-install-min-reqs: true
72-
coverage-upload: artifact
73-
strategy:
74-
fail-fast: false
75-
matrix:
76-
python-version: ["3.9", "3.10", "3.11"]
64+
- name: 🐍 Set up Python ${{ matrix.python-version }}
65+
uses: astral-sh/setup-uv@v6
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
enable-cache: true
69+
cache-dependency-glob: "**/pyproject.toml"
7770

78-
test-pydantic1:
79-
name: Test pydantic 1
80-
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
81-
with:
82-
os: ubuntu-latest
83-
python-version: 3.11
84-
qt: pyqt6
85-
pip-post-installs: '"pydantic<2"'
86-
coverage-upload: artifact
71+
- uses: pyvista/setup-headless-display-action@v4
72+
with:
73+
qt: true
74+
75+
- name: Install Dependencies
76+
run: uv sync --no-dev --group test --group ${{ matrix.add-group || 'test' }} --resolution ${{ matrix.resolution || 'highest'}}
77+
78+
- name: 🧪 Run Tests
79+
run: uv run coverage run -p -m pytest -v
80+
81+
# If something goes wrong with --pre tests, we can open an issue in the repo
82+
- name: 📝 Report --pre Failures
83+
if: failure() && github.event_name == 'schedule'
84+
uses: JasonEtco/create-an-issue@v2
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
PLATFORM: ${{ matrix.os }}
88+
PYTHON: ${{ matrix.python-version }}
89+
RUN_ID: ${{ github.run_id }}
90+
TITLE: "[test-bot] pip install --pre is failing"
91+
with:
92+
filename: .github/TEST_FAIL_TEMPLATE.md
93+
update_existing: true
94+
95+
- name: Upload coverage
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: covreport-${{ matrix.os }}-py${{ matrix.python-version }}-${{ matrix.add-group }}-${{ matrix.resolution }}
99+
path: ./.coverage*
100+
include-hidden-files: true
87101

88102
upload_coverage:
89103
if: always()
90-
needs: [test, test-min-reqs, test-pydantic1]
104+
needs: [test]
91105
uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2
92106
secrets: inherit
93107

@@ -97,7 +111,6 @@ jobs:
97111
dependency-repo: ${{ matrix.package }}
98112
dependency-ref: ${{ matrix.package-version }}
99113
dependency-extras: ${{ matrix.package-extras || 'testing' }}
100-
host-extras: "testing"
101114
qt: pyqt5
102115
python-version: "3.10"
103116
post-install-cmd: "python -m pip install pytest-pretty lxml_html_clean" # just for napari
@@ -107,7 +120,7 @@ jobs:
107120
matrix:
108121
include:
109122
- package: napari/napari
110-
pytest-args: napari/_tests/test_magicgui.py
123+
pytest-args: src/napari/_tests/test_magicgui.py --import-mode=importlib
111124
- package: napari/napari
112125
package-version: "v0.4.19.post1"
113126
pytest-args: napari/_tests/test_magicgui.py
@@ -116,34 +129,33 @@ jobs:
116129
package-extras: test
117130
pytest-args: package/tests/test_PartSeg/test_napari_widgets.py
118131

119-
deploy:
132+
build-and-inspect-package:
133+
name: Build & inspect package.
120134
needs: test
121135
runs-on: ubuntu-latest
122-
if: ${{ github.repository == 'pyapp-kit/magicgui' && contains(github.ref, 'tags') }}
123-
permissions:
124-
id-token: write
125-
contents: write
126136
steps:
127137
- uses: actions/checkout@v4
128138
with:
129139
fetch-depth: 0
130-
- name: Set up Python
131-
uses: actions/setup-python@v5
132-
with:
133-
python-version: "3.x"
134-
- name: Install dependencies
135-
run: |
136-
python -m pip install --upgrade pip
137-
pip install -U setuptools setuptools_scm wheel twine build
138-
- name: Build
139-
run: |
140-
git tag
141-
python -m build
142-
twine check dist/*
143-
- name: Create Release
144-
uses: softprops/action-gh-release@v2
140+
- uses: hynek/build-and-inspect-python-package@v2
141+
142+
upload-to-pypi:
143+
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' && github.repository == 'pyapp-kit/magicgui'
144+
name: Upload package to PyPI
145+
needs: build-and-inspect-package
146+
runs-on: ubuntu-latest
147+
permissions:
148+
id-token: write
149+
contents: write
150+
steps:
151+
- name: Download built artifact to dist/
152+
uses: actions/download-artifact@v4
145153
with:
146-
files: dist/*
147-
body_path: ${{ github.workspace }}/CHANGELOG.md
148-
- name: Publish to PyPI
154+
name: Packages
155+
path: dist
156+
- name: 🚢 Publish to PyPI
149157
uses: pypa/gh-action-pypi-publish@release/v1
158+
- uses: softprops/action-gh-release@v2
159+
with:
160+
generate_release_notes: true
161+
files: './dist/*'

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ ci:
55

66
repos:
77
- repo: https://github.com/abravalheri/validate-pyproject
8-
rev: v0.23
8+
rev: v0.24.1
99
hooks:
1010
- id: validate-pyproject
1111

1212
- repo: https://github.com/crate-ci/typos
13-
rev: v1.30.0
13+
rev: v1.33.1
1414
hooks:
1515
- id: typos
1616

1717
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: v0.9.9
18+
rev: v0.11.12
1919
hooks:
20-
- id: ruff
20+
- id: ruff-check
2121
args: ["--fix", "--unsafe-fixes"]
2222
- id: ruff-format
2323

2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.15.0
25+
rev: v1.16.0
2626
hooks:
2727
- id: mypy
2828
files: "^src/"

0 commit comments

Comments
 (0)