-
Notifications
You must be signed in to change notification settings - Fork 2.9k
How to configure uv to use namespace packages? #10628
Description
While migrating a project from setuptools to uv I cannot get a namespace package correct:
First the "setuptools version" of the project:
It contains directives for finding the namespace packages (in setup.cfg):
...
package_dir = =src
packages = find_namespace:
[options.packages.find]
where = src
include = a.b.*
...
The file layout of MyPackage is as follows:
pyproject.toml
setup.cfg
src/a/b/MyPackage
__init__.py
SomeSubPackage
__init__.py
pip install -e .
MyPackage is now available using namespace "a.b":
import a.b.MyPackage
Now the "uv version" of the project:
(relevant parts)
It uses following lines in pyproject.toml for specifiying the package:
...
[tool.hatch.build.targets.wheel]
packages = ["src/a/b/MyPackage"]
...
uv sync
will get the depenedencies and creates an editable installation in .venv
This makes MyPackage available without the namespace part
import MyPackage
Which is not what I want, MyPackage should be available in namespace "a.b"
I cannot not find a way how to configure it such that i can import the package as "a.b.MPackage".
I tried variations like:
packages = ["src/*"]
But none of the variations work.