Skip to content

🐛 Bug: uv build fails with invalid Python module path with no clear error message #15702

@DhavalGojiya

Description

@DhavalGojiya

Summary

Project Structure

I am working with a Django project where:

  • Not using uv as project management
  • Using uv only for backend build

electo_premium/
    client/
    newspaper/
    payments/
    pyproject.toml
    manage.py
    __init__.py   # necessary for uv build

Note: If you are wondering why I am building the whole project as a wheel:

To use Apache Airflow, I need to place my Django source code inside the virtual environment's site-packages/ folder on the AWS Airflow server so that my Django code is also accessible in AWS Airflow.

For example, this import should work at aws airflow environment:

from electo_premium.newspaper.models import NewsLetter

pyproject.toml

# pyproject.toml - content

[build-system]
requires = ["uv_build>=0.8.12,<0.9.0"]
build-backend = "uv_build"

[tool.uv.build-backend]
module-name = "electo_premium"
module-root = "../"  # Go one step backward (Not sure if going backward is even possible)

Command Run

At the same directory where manage.py exists:

uv build

Actual Output

Building source distribution (uv build backend)...
Building wheel from source distribution (uv build backend)...
  × Failed to build `/home/trootech/Production Projects/electo/electo_premium`
  ╰─▶ Expected a Python module at: `/home/trootech/.cache/uv/sdists-v9/.tmpR0ugJW/electo_premium-1.0.0/../electo_premium/__init__.py`

❌ Problem

The error message seems invalid/weird — it is looking for the module at a path containing /home/trootech/.cache/uv/sdists-v9/.tmpR0ugJW/electo_premium-1.0.0/../electo_premium/__init__.py, which doesn’t look correct.

✅ Expected Behavior

uv build should correctly locate the __init__.py inside the project and build the package without path resolution errors.


📝 Notes

  • The __init__.py file does exist inside electo_premium/.
  • The error message suggests that path resolution may be going one step too far (../) during build.

Platform

Linux 6.8.0-45-generic x86_64 GNU/Linux

Version

uv 0.8.15

Python version

Python 3.12.7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions