Skip to content

Commit 4f48957

Browse files
authored
Migrate to uv and dependency groups (#1024)
* Migrate to uv and dependency groups * uv lock --upgrade
1 parent 756d39a commit 4f48957

9 files changed

Lines changed: 1575 additions & 55 deletions

File tree

.github/dependabot.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: "/"
55
schedule:
6-
interval: daily
7-
open-pull-requests-limit: 10
6+
interval: monthly
7+
groups:
8+
all-dependencies:
9+
patterns: ["*"]
810
- package-ecosystem: "github-actions"
911
directory: "/"
1012
schedule:
1113
interval: "monthly"
14+
groups:
15+
all-actions:
16+
patterns: ["*"]

.github/workflows/build-release.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,22 @@ jobs:
2323
- { name: "3.14-madev", python: "3.14", tox: py314-marshmallowdev }
2424
steps:
2525
- uses: actions/checkout@v6.0.2
26-
- uses: actions/setup-python@v6
26+
- uses: astral-sh/setup-uv@v7
2727
with:
2828
python-version: ${{ matrix.python }}
29-
- run: pip install tox
30-
- run: tox -e${{ matrix.tox }}
29+
enable-cache: true
30+
- run: uv run tox -e${{ matrix.tox }}
3131
build:
3232
name: Build package
3333
runs-on: ubuntu-latest
3434
steps:
3535
- uses: actions/checkout@v6.0.2
36-
- uses: actions/setup-python@v6
36+
- uses: astral-sh/setup-uv@v7
3737
with:
3838
python-version: "3.14"
39-
- name: Install pypa/build
40-
run: python -m pip install build
41-
- name: Build a binary wheel and a source tarball
42-
run: python -m build
43-
- name: Install twine
44-
run: python -m pip install twine
45-
- name: Check build
46-
run: python -m twine check --strict dist/*
39+
enable-cache: true
40+
- run: uv build
41+
- run: uvx twine check --strict dist/*
4742
- name: Store the distribution packages
4843
uses: actions/upload-artifact@v7
4944
with:
@@ -56,11 +51,11 @@ jobs:
5651
runs-on: ubuntu-latest
5752
steps:
5853
- uses: actions/checkout@v6.0.2
59-
- uses: actions/setup-python@v6
54+
- uses: astral-sh/setup-uv@v7
6055
with:
6156
python-version: "3.14"
62-
- run: python -m pip install tox
63-
- run: python -m tox -e lint
57+
enable-cache: true
58+
- run: uv run tox -e lint
6459
publish-to-pypi:
6560
name: PyPI release
6661
if: startsWith(github.ref, 'refs/tags/')

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ repos:
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: ["marshmallow>=3.24.1,<5", "types-PyYAML"]
24+
- repo: https://github.com/astral-sh/uv-pre-commit
25+
rev: 0.10.9
26+
hooks:
27+
- id: uv-lock

.readthedocs.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://docs.readthedocs.com/platform/stable/build-customization.html#install-dependencies-with-uv
2+
version: 2
3+
sphinx:
4+
configuration: docs/conf.py
5+
formats:
6+
- pdf
7+
build:
8+
os: ubuntu-24.04
9+
tools:
10+
python: "3.13"
11+
jobs:
12+
pre_create_environment:
13+
- asdf plugin add uv
14+
- asdf install uv latest
15+
- asdf global uv latest
16+
create_environment:
17+
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
18+
install:
19+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs --extra marshmallow

CONTRIBUTING.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,19 @@ Setting Up for Local Development
2828
$ git clone https://github.com/marshmallow-code/apispec.git
2929
$ cd apispec
3030

31-
2. Install development requirements. **It is highly recommended that you use a virtualenv.**
32-
Use the following command to install an editable version of
33-
apispec along with its development requirements.
31+
2. Install `uv <https://docs.astral.sh/uv/getting-started/installation/>`_.
32+
33+
3. Install development requirements.
3434

3535
::
3636

37-
# After activating your virtualenv
38-
$ pip install -e '.[dev]'
37+
$ uv sync
3938

40-
3. Install the pre-commit hooks, which will format and lint your git staged files.
39+
4. (Optional but recommended) Install the pre-commit hooks, which will format and lint your git staged files.
4140

4241
::
4342

44-
# The pre-commit CLI was installed above
45-
$ pre-commit install
43+
$ uv run pre-commit install --allow-missing-config
4644

4745

4846
Git Branch Structure
@@ -93,15 +91,15 @@ Running Tests
9391

9492
To run all tests: ::
9593

96-
$ pytest
94+
$ uv run pytest
9795

9896
To run syntax checks: ::
9997

100-
$ tox -e lint
98+
$ uv run tox -e lint
10199

102100
(Optional) To run tests in all supported Python versions in their own virtual environments (must have each interpreter installed): ::
103101

104-
$ tox
102+
$ uv run tox
105103

106104
Documentation
107105
+++++++++++++
@@ -110,7 +108,7 @@ Contributions to the documentation are welcome. Documentation is written in `reS
110108

111109
To build the docs in "watch" mode: ::
112110

113-
$ tox -e docs-serve
111+
$ uv run tox -e docs-serve
114112

115113
Changes in the `docs/` directory will automatically trigger a rebuild.
116114

pyproject.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@ Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-a
4444
[project.optional-dependencies]
4545
yaml = ["PyYAML>=3.10"]
4646
marshmallow = ["marshmallow>=3.18.0"]
47+
48+
[dependency-groups]
4749
docs = [
48-
"apispec[marshmallow]",
49-
"pyyaml==6.0.3",
50-
"sphinx==9.1.0",
51-
"sphinx-issues==6.0.0",
52-
"sphinx-rtd-theme==3.1.0",
50+
"marshmallow>=3.18.0",
51+
"pyyaml",
52+
"sphinx-issues",
53+
"sphinx-rtd-theme",
54+
"sphinx>=8.1",
5355
]
54-
tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.8.4", "pytest"]
55-
dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"]
56+
tests = ["openapi-spec-validator", "pytest"]
57+
dev = [{ include-group = "tests" }, "tox", "tox-uv", "pre-commit>=3.5,<5.0"]
58+
59+
[tool.uv]
60+
default-groups = ["dev"]
5661

5762
[build-system]
5863
requires = ["flit_core<4"]

readthedocs.yml

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

tox.ini

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ envlist=
77
docs
88

99
[testenv]
10-
extras = tests
10+
extras = yaml,marshmallow
11+
dependency_groups = tests
1112
deps =
1213
marshmallow3: marshmallow>=3.18.0,<4.0.0
1314
marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz
@@ -20,14 +21,16 @@ skip_install = true
2021
commands = pre-commit run --all-files
2122

2223
[testenv:docs]
23-
extras = docs
24+
extras = marshmallow
25+
dependency_groups = docs
2426
commands = sphinx-build docs/ docs/_build {posargs}
2527

2628
; Below tasks are for development only (not run in CI)
2729

2830
[testenv:docs-serve]
2931
deps = sphinx-autobuild
30-
extras = docs
32+
extras = marshmallow
33+
dependency_groups = docs
3134
commands = sphinx-autobuild --port=0 --open-browser --delay=2 docs/ docs/_build {posargs} --watch src --watch CONTRIBUTING.rst --watch README.rst
3235

3336
[testenv:readme-serve]

0 commit comments

Comments
 (0)