Skip to content

Adding UV package manager support for Python projects#4980

Open
GuillemSeCa wants to merge 1 commit intoaboutcode-org:developfrom
GuillemSeCa:feature/parse-uv_package
Open

Adding UV package manager support for Python projects#4980
GuillemSeCa wants to merge 1 commit intoaboutcode-org:developfrom
GuillemSeCa:feature/parse-uv_package

Conversation

@GuillemSeCa
Copy link
Copy Markdown

@GuillemSeCa GuillemSeCa commented May 6, 2026

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

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Signed-off-by: Guillem Serra Cazorla [email protected]

@GuillemSeCa GuillemSeCa marked this pull request as ready for review May 6, 2026 11:56
Copy link
Copy Markdown
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GuillemSeCa Thank you++. This looks good overall. Do you mind to add a DCO signoff to your commit?

NB: this is timely as @AyanSinhaMahapatra is playing to switch to uv for ScanCode itself...

@AyanSinhaMahapatra do you mind to check the pinning issue on the doc CI action? And merge at your convenience.

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: aboutcode-org#4501
Signed-off-by: Guillem Serra Cazorla <[email protected]>
@GuillemSeCa GuillemSeCa force-pushed the feature/parse-uv_package branch from 19a432a to c27f6ee Compare May 6, 2026 13:36
@GuillemSeCa
Copy link
Copy Markdown
Author

I have added the signoff @pombredanne!

@GuillemSeCa GuillemSeCa requested a review from pombredanne May 6, 2026 13:43
Copy link
Copy Markdown
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me on the code. We still some minimal doc for the thirdparty inclusion.

@pombredanne
Copy link
Copy Markdown
Member

For https://github.com/aboutcode-org/scancode-toolkit/pull/4980/changes#diff-68efae3999818a948ae49f2a73f0f6e7b6c02f1e2d4c9f1438b80d547f6de9f5R408
...
Do you mind to add their MIT license as a comment in there, and add an ABOUT file + license file for these too? We use that to documented vendored and copied code and you can get an example there https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/licensedcode/languages.py.ABOUT

We do not want to be the proverbial cobbler's son going barefoot!

@pombredanne
Copy link
Copy Markdown
Member

Ignore my previous comment at #4980 (comment)

I thought incorrectly you had copied Python code from attrs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants