Commit 9d4409f
committed
feat: Add UV package manager support for Python projects
Add support for parsing Python projects managed with the UV package
manager (https://docs.astral.sh/uv/). Two new package data handlers are
added in packagedcode.pypi:
- UvPyprojectTomlHandler parses pyproject.toml files containing a
[tool.uv] table. It collects the standard PEP 621 [project] metadata,
optional-dependencies, and PEP 735 [dependency-groups] (with
include-group references skipped as forward references).
- UvLockHandler parses uv.lock files. Each [[package]] entry becomes a
pinned, virtual resolved package; the editable root project entry is
skipped since it is parsed independently from pyproject.toml. SHA-256
hashes and the exact sdist URL recorded in the lock file are
preserved, and PyPI URLs are populated via get_pypi_urls.
A shared BaseUvPythonLayout assembles the package by walking from
either pyproject.toml or uv.lock to its sibling, mirroring the existing
Poetry layout. PyprojectTomlHandler is updated to skip pyproject.toml
files that belong to a UV project so that the dedicated handler runs.
Test fixtures are derived from python-attrs/attrs 26.1.0
(https://github.com/python-attrs/attrs, MIT-licensed) and trimmed to
the relevant parts for parser and end-to-end package-assembly coverage.
Refs: #4501
Signed-off-by: Guillem Serra Cazorla <gserracazorla@gmail.com>
Signed-off-by: Guillem Serra Cazorla <guillem@meta.com>1 parent 6570c13 commit 9d4409f
10 files changed
Lines changed: 3478 additions & 760 deletions
File tree
- src/packagedcode
- tests/packagedcode
- data
- plugin
- pypi/uv
- attrs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
790 | 790 | | |
791 | 791 | | |
792 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
793 | 807 | | |
794 | 808 | | |
795 | 809 | | |
| |||
0 commit comments