You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The __init__.py file is optional, but if you download the repository https://github.com/astral-sh/uv-fastapi-example (a fresh copy, don't re-use the repository) and remove the app/__init__.py file, when you run:
uv run fastapi dev app/main.py
then you get this error:
Using Python 3.12.1 interpreter at: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
Creating virtualenv at: .venv
error: Failed to prepare distributions
Caused by: Failed to fetch wheel: app @ file:///Users/andreu/Git/Andreu/uv-fastapi-example
Caused by: Build backend failed to build wheel through `build_editable()` with exit status: 1
--- stdout:
--- stderr:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/build.py", line 83, in build_editable
return os.path.basename(next(builder.build(directory=wheel_directory, versions=['editable'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build
artifact = version_api[version](directory, **build_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 494, in build_editable
return self.build_editable_detection(directory, **build_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 505, in build_editable_detection
for included_file in self.recurse_selected_project_files():
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 180, in recurse_selected_project_files
if self.config.only_include:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/config.py", line 806, in only_include
only_include = only_include_config.get('only-include', self.default_only_include()) or self.packages
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 260, in default_only_include
return self.default_file_selection_options.only_include
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/functools.py", line 995, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/Users/.../Library/Caches/uv/builds-v0/.tmpfYT0UH/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 248, in default_file_selection_options
raise ValueError(message)
ValueError: Unable to determine which files to ship inside the wheel using the following heuristics: https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection
The most likely cause of this is that there is no directory that matches the name of your project (app).
At least one file selection option must be defined in the `tool.hatch.build.targets.wheel` table, see: https://hatch.pypa.io/latest/config/build/
As an example, if you intend to ship a directory named `foo` that resides within a `src` directory located at the root of your project, you can define the following:
[tool.hatch.build.targets.wheel]
packages = ["src/foo"]
uv version: 0.3.2
The text was updated successfully, but these errors were encountered:
I think describing __init__.py as optional is a bit of a misnomer. Python code sometimes works without an __init__.py due to namespace packages, but that's often "by accident". Regardless, this would be fixed by #6585.
This should be fixed in v0.4.0. Projects that omit [build-system] will no longer be built and installed by default. You can also set tool.uv.package = false or tool.uv.package = false to control the behavior explicitly.
The
__init__.py
file is optional, but if you download the repository https://github.com/astral-sh/uv-fastapi-example (a fresh copy, don't re-use the repository) and remove theapp/__init__.py
file, when you run:then you get this error:
uv version: 0.3.2
The text was updated successfully, but these errors were encountered: