Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv build fails to include modules that have symlinks elsewhere in project #10915

Open
tcjennings opened this issue Jan 23, 2025 · 4 comments
Open
Labels
compatibility Compatibility with a specification or another tool question Asking for clarification or support

Comments

@tcjennings
Copy link

tcjennings commented Jan 23, 2025

Summary

As best as I can tell, uv build refuses to add modules to a wheel file when those modules have symlinks elsewhere in the project. These symlinks are not otherwise involved in the package tree. hatch build still works correctly.

Minimal Reproducible Example

  • uv 0.5.23
uv init --package youvee-test
cd youvee-test
mkdir -p src/youvee_test/foo/templates
mkdir -p src/youvee_test/foo/settings

touch src/youvee_test/__init__.py
touch src/youvee_test/foo/__init__.py
touch src/youvee_test/foo/settings/__init__.py
touch src/youvee_test/foo/templates/__init__.py
touch src/youvee_test/foo/templates/module.py
touch src/youvee_test/foo/templates/not_py.yaml

pyproject.toml

[project]
name = "youvee-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
    { name = "...", email = "..." }
]
requires-python = ">=3.12"
dependencies = []

[project.scripts]
youvee-test = "youvee_test:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

uv build creates a correct wheel at this point:

❯ unzip -l dist/youvee_test-0.1.0-py3-none-any.whl
Archive:  dist/youvee_test-0.1.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
       57  02-02-2020 00:00   youvee_test/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/settings/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/templates/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/templates/module.py
        0  02-02-2020 00:00   youvee_test/foo/templates/not_py.yaml
      166  02-02-2020 00:00   youvee_test-0.1.0.dist-info/METADATA
       87  02-02-2020 00:00   youvee_test-0.1.0.dist-info/WHEEL
       49  02-02-2020 00:00   youvee_test-0.1.0.dist-info/entry_points.txt
      834  02-02-2020 00:00   youvee_test-0.1.0.dist-info/RECORD
---------                     -------
     1193                     10 files

Add a symlink farm to the project root.

mkdir ./foo
pushd foo
ln -s ../src/youvee_test/foo/settings .
ln -s ../src/youvee_test/foo/templates .
popd

uv build creates an incorrect wheel now:

❯ unzip -l dist/youvee_test-0.1.0-py3-none-any.whl
Archive:  dist/youvee_test-0.1.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
       57  02-02-2020 00:00   youvee_test/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/__init__.py
      166  02-02-2020 00:00   youvee_test-0.1.0.dist-info/METADATA
       87  02-02-2020 00:00   youvee_test-0.1.0.dist-info/WHEEL
       49  02-02-2020 00:00   youvee_test-0.1.0.dist-info/entry_points.txt
      475  02-02-2020 00:00   youvee_test-0.1.0.dist-info/RECORD
---------                     -------
      834                     6 files

hatch build creates a correct wheel:

❯ unzip -l dist/youvee_test-0.1.0-py3-none-any.whl
Archive:  dist/youvee_test-0.1.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
       57  02-02-2020 00:00   youvee_test/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/settings/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/templates/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/templates/module.py
        0  02-02-2020 00:00   youvee_test/foo/templates/not_py.yaml
      166  02-02-2020 00:00   youvee_test-0.1.0.dist-info/METADATA
       87  02-02-2020 00:00   youvee_test-0.1.0.dist-info/WHEEL
       49  02-02-2020 00:00   youvee_test-0.1.0.dist-info/entry_points.txt
      836  02-02-2020 00:00   youvee_test-0.1.0.dist-info/RECORD
---------                     -------
     1195                     10 files

Remove a symlink from the farm

rm foo/settings

uv build is partially correct: the module that is not symlinked into the farm is now included:

❯ unzip -l dist/youvee_test-0.1.0-py3-none-any.whl
Archive:  dist/youvee_test-0.1.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
       57  02-02-2020 00:00   youvee_test/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/__init__.py
        0  02-02-2020 00:00   youvee_test/foo/settings/__init__.py
      166  02-02-2020 00:00   youvee_test-0.1.0.dist-info/METADATA
       87  02-02-2020 00:00   youvee_test-0.1.0.dist-info/WHEEL
       49  02-02-2020 00:00   youvee_test-0.1.0.dist-info/entry_points.txt
      565  02-02-2020 00:00   youvee_test-0.1.0.dist-info/RECORD
---------                     -------
      924                     7 files

Platform

Darwin 24.1.0 arm64

Version

uv 0.5.23 (ba42467 2025-01-23)

Python version

Python 3.13.0, Python 3.12.7

@tcjennings tcjennings added the bug Something isn't working label Jan 23, 2025
@charliermarsh
Copy link
Member

Does python -m build (using https://github.com/pypa/build) produce the same result?

@tcjennings
Copy link
Author

For what it's worth, python -m build (without involving uv at all) has the same behavior.

rm -rf .venv
python -m venv .venv
activate .venv/bin/activate
pip install build
python -m build

@zanieb
Copy link
Member

zanieb commented Jan 23, 2025

If python -m build has the same behavior as uv build then this is a Hatch-specific problem, I think.

@tcjennings
Copy link
Author

I think I found the incantation that works around whatever the problem is: explicitly exclude and skip the symlink farm directory.

pyproject.toml:

[tool.hatch.build]
skip-excluded-dirs = true
exclude = ["/foo"]

@zanieb zanieb added question Asking for clarification or support compatibility Compatibility with a specification or another tool and removed bug Something isn't working labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with a specification or another tool question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

3 participants