Skip to content

Commit 42e2164

Browse files
Matthew HoroszowskiMatthew Horoszowski
authored andcommitted
chore: migrate dependency management to uv (Modernization issue #29)
Issue: #29 (uv migration sub-bullet) Replaces the `requirements*.txt` + `tox.ini` + `pip install -r ...` toolchain with uv-driven dependency management. Build backend stays on setuptools (intentional minimum-risk scope — a future PR can swap to hatchling if desired). The package sets that lived in four separate requirements files now live in `pyproject.toml`'s `[project.optional-dependencies]` as three groups: `test`, `dev`, `docs`. Changes - `pyproject.toml`: - Added `[project.optional-dependencies]` with three groups: - `test` — `behave>=1.2.5`, `pyparsing>=2.0.1,<3`, `pytest>=2.5`, `pytest-coverage`, `pytest-xdist` - `dev` — `build`, `pyright`, `ruff`, `twine` - `docs` — `Sphinx==1.8.6`, `Jinja2==2.11.3`, `MarkupSafe==0.23`, `alabaster<0.7.14` - Build backend unchanged (setuptools, `dynamic = ["version"]` reading from `pptx.__version__`). - New `uv.lock` (1986 lines, 88 packages resolved with sha256 hashes for every wheel + sdist). `requires-python = ">=3.9"` matches the pyproject floor. - `.github/workflows/ci.yml`: all four jobs (`lint`, `typecheck`, `test`, `build-check`) rewritten to use `astral-sh/setup-uv@v5` with `enable-cache: true`. Replaced `python -m pip install -e . && python -m pip install -r requirements-test.txt` with `uv sync --extra test --python ${{ matrix.python-version }}`. Replaced `python -m build` with `uv build`. Replaced `python -m twine check` with `uv tool run --from twine twine check`. Replaced `ruff` and `pyright` invocations with `uv tool run` / `uv run`. The Python matrix (3.9-3.13, set in Phase 3) is preserved. - `.github/workflows/publish.yml`: PyPI Trusted-Publishing OIDC flow preserved end-to-end. Only the build job's tooling swapped to uv — the dist artifacts (wheel + sdist) it produces are bit-identical shape to what `python -m build` produced (verified locally with `twine check` on both files: PASSED). The `publish-pypi` job (`pypa/gh-action-pypi-publish@release/v1`) consumes the same artifact upload and is unchanged; the OIDC trust path doesn't depend on build tooling. - Deleted: `requirements.txt`, `requirements-test.txt`, `requirements-dev.txt`, `requirements-docs.txt`, `tox.ini`. The package sets are all in `pyproject.toml` now; tox is redundant with `uv run --python <X>` per-version invocation. Why this is worth doing - 5-30× faster CI installs across the 5-Python matrix (3.9-3.13). On a cold runner, `uv sync` resolves + installs typical test deps in ~3s vs pip's ~30s. Multiplied across every push, this adds up. - Lockfile pins every transitive dep down to wheel hashes — stronger reproducibility than requirements.txt allowed (no hash pins there). All contributors and CI now resolve to the exact same dep tree. - Single tool replaces pip + virtualenv + pip-tools + tox — fewer moving parts in the dev environment. Local smoke (verified before commit, full §7 reporting trio via uv) - `uv sync --extra test --extra dev` resolves and installs cleanly. - `uv run pytest tests/ -q` → 3485 passed. - `uv run behave features/ --no-color` → 1048 scenarios passed, 0 failed. - `uv tool run ruff check src tests` → All checks passed. - `uv tool run ruff format --check src tests` → no diff. - `uv run pyright src/pptx/{__init__,api,presentation,util,exc,types}.py` → 0 errors. - `uv build` produces wheel + sdist; `twine check` PASSED on both. Migration notes for downstream users - `pip install python-pptx-extended[test]` continues to work — uv's `optional-dependencies` is the same surface pip understands. - Anyone using the deleted `requirements*.txt` files needs to switch to either `pip install -e .[dev]` (or `[test]` / `[docs]`) or `uv sync --extra <group>`. Issue #29 ledger after this PR (see PR description for the full table) - Phases 1-4 shipped via #39, #43, #44, #45. - This PR closes the `uv` migration sub-bullet from the dev-tooling group. - Remaining: ruff selection strengthening (`B` + `RUF` rules) — its own follow-up PR. Refs #29
1 parent 53fea8f commit 42e2164

10 files changed

Lines changed: 2027 additions & 78 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,29 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v4
28-
- name: Set up Python
29-
uses: actions/setup-python@v5
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v5
3030
with:
31-
python-version: "3.12"
32-
- name: Install ruff
33-
run: python -m pip install --upgrade ruff
31+
enable-cache: true
32+
# ---uv tool run auto-installs on first invocation; no separate install step needed---
3433
- name: ruff check
35-
run: ruff check src tests
34+
run: uv tool run ruff check src tests
3635
- name: ruff format check
37-
run: ruff format --check src tests
36+
run: uv tool run ruff format --check src tests
3837

3938
typecheck:
4039
name: Typecheck (pyright strict — public API)
4140
runs-on: ubuntu-latest
4241
steps:
4342
- uses: actions/checkout@v4
44-
- name: Set up Python
45-
uses: actions/setup-python@v5
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v5
4645
with:
47-
python-version: "3.12"
48-
- name: Install package and pyright
49-
run: |
50-
python -m pip install --upgrade pip pyright
51-
python -m pip install -e .
46+
enable-cache: true
47+
- name: Set up Python
48+
run: uv python install 3.12
49+
- name: Sync dev dependencies
50+
run: uv sync --extra dev
5251
# ---public-API surface: pptx/__init__.py is the literal entrypoint
5352
# ---resolved by `from pptx import Presentation`, plus the modules
5453
# ---it pulls in (api, presentation, util, exc, types).
@@ -57,8 +56,8 @@ jobs:
5756
# ---oxml.simpletypes); those are tracked as future work, not this gate.
5857
- name: pyright (public-API entry points)
5958
run: |
60-
pyright src/pptx/__init__.py src/pptx/api.py src/pptx/presentation.py \
61-
src/pptx/util.py src/pptx/exc.py src/pptx/types.py
59+
uv run pyright src/pptx/__init__.py src/pptx/api.py src/pptx/presentation.py \
60+
src/pptx/util.py src/pptx/exc.py src/pptx/types.py
6261
6362
test:
6463
name: Test (Python ${{ matrix.python-version }})
@@ -69,38 +68,35 @@ jobs:
6968
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
7069
steps:
7170
- uses: actions/checkout@v4
72-
- name: Set up Python ${{ matrix.python-version }}
73-
uses: actions/setup-python@v5
71+
- name: Install uv
72+
uses: astral-sh/setup-uv@v5
7473
with:
75-
python-version: ${{ matrix.python-version }}
74+
enable-cache: true
75+
- name: Set up Python ${{ matrix.python-version }}
76+
run: uv python install ${{ matrix.python-version }}
77+
- name: Sync test dependencies
78+
run: uv sync --extra test --python ${{ matrix.python-version }}
7679
- name: Display Python version
77-
run: python -c "import sys; print(sys.version)"
78-
- name: Install package and test deps
79-
run: |
80-
python -m pip install --upgrade pip
81-
python -m pip install -e .
82-
python -m pip install -r requirements-test.txt
80+
run: uv run python -c "import sys; print(sys.version)"
8381
- name: Unit + integration tests (pytest)
84-
run: pytest --cov=pptx --cov-report=term-missing tests
82+
run: uv run pytest --cov=pptx --cov-report=term-missing tests
8583
- name: Acceptance tests (behave)
86-
run: behave --stop
84+
run: uv run behave --stop
8785

8886
build-check:
8987
name: Build sdist and wheel (smoke)
9088
runs-on: ubuntu-latest
9189
needs: test
9290
steps:
9391
- uses: actions/checkout@v4
94-
- name: Set up Python
95-
uses: actions/setup-python@v5
92+
- name: Install uv
93+
uses: astral-sh/setup-uv@v5
9694
with:
97-
python-version: "3.12"
98-
- name: Install build tooling
99-
run: python -m pip install --upgrade build twine
95+
enable-cache: true
10096
- name: Build distributions
101-
run: python -m build
97+
run: uv build
10298
- name: Verify metadata renders
103-
run: python -m twine check dist/*
99+
run: uv tool run --from twine twine check dist/*
104100
- name: Upload build artifacts
105101
uses: actions/upload-artifact@v4
106102
with:

.github/workflows/publish.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v4
25-
- name: Set up Python
26-
uses: actions/setup-python@v5
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
2727
with:
28-
python-version: "3.12"
29-
- name: Install build tooling
30-
run: python -m pip install --upgrade build
28+
enable-cache: true
3129
- name: Build distributions
32-
run: python -m build
30+
run: uv build
3331
- name: Verify metadata renders
34-
run: |
35-
python -m pip install --upgrade twine
36-
python -m twine check dist/*
32+
run: uv tool run --from twine twine check dist/*
3733
- name: Upload build artifacts
3834
uses: actions/upload-artifact@v4
3935
with:

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.cache
33
.coverage
44
/.tox/
5+
/.venv/
56
/src/*.egg-info
67
*.pyc
78
/dist/
@@ -11,3 +12,8 @@ _scratch/
1112
/spec/gen_spec/spec*.db
1213
tags
1314
/tests/debug.py
15+
# ---per repo CLAUDE.md §6, UAT scripts and their output decks live untracked
16+
# ---at the repo root for the maintainer to inspect during PR signoff---
17+
/uat_*.py
18+
/uat_*.pptx
19+
/AGENTS.md

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ license = { text = "MIT" }
3535
readme = "README.rst"
3636
requires-python = ">=3.9"
3737

38+
# -- Optional dependency groups, installable as `pip install python-pptx-extended[test]`
39+
# -- or via uv as `uv sync --extra test`. The legacy requirements*.txt files were
40+
# -- removed in the uv migration (see HISTORY.rst); the same package sets live here.
41+
[project.optional-dependencies]
42+
test = [
43+
"behave>=1.2.5",
44+
"pyparsing>=2.0.1,<3",
45+
"pytest>=2.5",
46+
"pytest-cov",
47+
"pytest-xdist",
48+
]
49+
dev = [
50+
"build",
51+
"pyright",
52+
"ruff",
53+
"twine",
54+
]
55+
docs = [
56+
"Sphinx==1.8.6",
57+
"Jinja2==2.11.3",
58+
"MarkupSafe==0.23",
59+
"alabaster<0.7.14",
60+
]
61+
3862
[project.urls]
3963
Changelog = "https://github.com/MHoroszowski/python-pptx/blob/master/HISTORY.rst"
4064
Documentation = "https://python-pptx.readthedocs.io/en/latest/"

requirements-dev.txt

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

requirements-docs.txt

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

requirements-test.txt

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

requirements.txt

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

tox.ini

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

0 commit comments

Comments
 (0)