Skip to content

uv build does not warn or fail when license files do not exist #16693

@N-Wouda

Description

@N-Wouda

Summary

uv build does not inform the user that a license file specified in the license-files field could not be found. This has unintended consequences, since after building the package, its .dist-info directory contains an empty licenses/ directory.

I understand the packaging guide entry about license-files as requiring each glob (including literal globs) to match at least one file:

  • Each glob must match at least one file.

If no matches are found that seems to me misspecified, and worth pointing out to the user.

The current implementation allows the build to complete, which presents its own problems. If the built package is then installed in another project, uv cannot also remove it fully (it does not remove the actually empty .dist-info/licenses/ directory that is supposed to contain the license files), leaving the managed .venv in a broken state. But this follow-up issue is caused by the previous problem, so perhaps addressing the root problem suffices.

Steps to reproduce:

  1. Run
uv init --package uvtest
  1. Add
license-files = ["abc"]

to the [project] table.

  1. Run
uv build -vvv

This does not raise or warn that the license file abc could not be found. Output:

Details
DEBUG uv 0.9.8
TRACE Checking shared lock for `/home/niels/.cache/uv` at `/home/niels/.cache/uv/.lock`
DEBUG Acquired shared lock for `/home/niels/.cache/uv`
DEBUG Found workspace root: `/home/niels/projects/uvtest`
TRACE Discovering workspace members for: `/home/niels/projects/uvtest`
DEBUG Adding root workspace member: `/home/niels/projects/uvtest`
DEBUG Reading Python requests from version file at `/home/niels/projects/uvtest/.python-version`
DEBUG Searching for Python 3.10 in virtual environments, managed installations, or search path
TRACE Found cached interpreter info for Python 3.10.12, skipping query of: .venv/bin/python3
DEBUG Found `cpython-3.10.12-linux-x86_64-gnu` at `/home/niels/projects/uvtest/.venv/bin/python3` (virtual environment)
DEBUG Using request timeout of 30s
Building source distribution (uv build backend)...
DEBUG Found PEP 639 license declarations, using METADATA 2.4
DEBUG built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
TRACE Not a file in license files match: .
DEBUG Adding content files to source distribution
DEBUG Source root: src
DEBUG Module path: uvtest
TRACE Including readme at: README.md
TRACE Including license files at: abc`
DEBUG Source distribution includes: ["pyproject.toml", "src/uvtest/**", "README.md", "abc"]
DEBUG built glob set; 3 literals, 0 basenames, 0 extensions, 1 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG Source dist excludes: ["__pycache__", "*.pyc", "*.pyo"]
DEBUG built glob set; 0 literals, 1 basenames, 2 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG Adding to sdist: .
DEBUG Adding to sdist: README.md
DEBUG Adding to sdist: pyproject.toml
DEBUG Adding to sdist: src
DEBUG Adding to sdist: src/uvtest
DEBUG Adding to sdist: src/uvtest/__init__.py
DEBUG Visited 6 files for source dist build
Building wheel from source distribution (uv build backend)...
DEBUG Writing wheel at dist/uvtest-0.1.0-py3-none-any.whl
DEBUG Wheel excludes: ["__pycache__", "*.pyc", "*.pyo"]
DEBUG built glob set; 0 literals, 1 basenames, 2 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG Adding content files to wheel
DEBUG Source root: /home/niels/.cache/uv/sdists-v9/.tmpTE2im7/uvtest-0.1.0/src
DEBUG Module path: uvtest
DEBUG Adding to wheel: uvtest
TRACE Adding directory uvtest
DEBUG Adding to wheel: uvtest/__init__.py
TRACE Adding uvtest/__init__.py from /home/niels/.cache/uv/sdists-v9/.tmpTE2im7/uvtest-0.1.0/src/uvtest/__init__.py
DEBUG Visited 2 files for wheel build
DEBUG Adding license files
TRACE Including project.license-files at `/home/niels/.cache/uv/sdists-v9/.tmpTE2im7/uvtest-0.1.0` with `abc`
DEBUG built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
TRACE Adding directory uvtest-0.1.0.dist-info/licenses/
DEBUG Adding metadata files to wheel
TRACE Adding directory uvtest-0.1.0.dist-info
TRACE Adding uvtest-0.1.0.dist-info/WHEEL
TRACE Adding uvtest-0.1.0.dist-info/entry_points.txt
DEBUG Found PEP 639 license declarations, using METADATA 2.4
DEBUG built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
TRACE Not a file in license files match: .
TRACE Adding uvtest-0.1.0.dist-info/METADATA
TRACE Adding uvtest-0.1.0.dist-info/RECORD
TRACE Adding central directory
Successfully built dist/uvtest-0.1.0.tar.gz
Successfully built dist/uvtest-0.1.0-py3-none-any.whl
DEBUG Released lock at `/home/niels/.cache/uv/.lock`

Platform

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 GNU/Linux

Version

uv 0.9.8

Python version

Python 3.10.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions