Skip to content

Commit 9d4409f

Browse files
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

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Changelog
44
Next release
55
--------------
66

7+
- Add support for the Python UV package manager. Two new package data
8+
handlers parse ``pyproject.toml`` files containing a ``[tool.uv]`` table
9+
and ``uv.lock`` lockfiles, including PEP 735 ``[dependency-groups]``,
10+
and the package assembly walks both files together so that the project
11+
metadata and the resolved transitive dependencies are reported as a
12+
single Python package.
13+
https://github.com/aboutcode-org/scancode-toolkit/issues/4501
14+
715
v3.5.0 - 2026-01-15
816
-------------------
917

src/packagedcode/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@
174174
pypi.PyprojectTomlHandler,
175175
pypi.PoetryPyprojectTomlHandler,
176176
pypi.PoetryLockHandler,
177+
pypi.UvPyprojectTomlHandler,
178+
pypi.UvLockHandler,
177179
pypi.PythonEditableInstallationPkgInfoFile,
178180
pypi.PythonEggPkgInfoFile,
179181
pypi.PythonInstalledWheelMetadataFile,

src/packagedcode/pypi.py

Lines changed: 906 additions & 478 deletions
Large diffs are not rendered by default.

tests/packagedcode/data/plugin/plugins_list_linux.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,20 @@ Package type: pypi
790790
description: Python setup.py
791791
path_patterns: '*setup.py'
792792
--------------------------------------------
793+
Package type: pypi
794+
datasource_id: pypi_uv_lock
795+
documentation URL: https://docs.astral.sh/uv/concepts/projects/sync/#the-uvlock-file
796+
primary language: Python
797+
description: Python UV lockfile
798+
path_patterns: '*uv.lock'
799+
--------------------------------------------
800+
Package type: pypi
801+
datasource_id: pypi_uv_pyproject_toml
802+
documentation URL: https://docs.astral.sh/uv/concepts/projects/
803+
primary language: Python
804+
description: Python UV pyproject.toml
805+
path_patterns: '*pyproject.toml'
806+
--------------------------------------------
793807
Package type: pypi
794808
datasource_id: pypi_wheel
795809
documentation URL: https://peps.python.org/pep-0427/

0 commit comments

Comments
 (0)