-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Init project without src #6293
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
Comments
You can definitely remove the What are you looking to achieve? Why do you want a virtual layout? |
My problem is that the alternative santiago@192 test_uv % uv add pydantic
Using Python 3.12.4 interpreter at: /opt/homebrew/opt/[email protected]/bin/python3.12
Creating virtualenv at: .venv
Resolved 5 packages in 18ms
error: Failed to prepare distributions
Caused by: Failed to fetch wheel: test-uv @ file:///Users/santiago/Desktop/test_uv
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/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/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/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build
artifact = version_api[version](directory, **build_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 494, in build_editable
return self.build_editable_detection(directory, **build_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/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/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 180, in recurse_selected_project_files
if self.config.only_include:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/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/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 260, in default_only_include
return self.default_file_selection_options.only_include
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/functools.py", line 995, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/Users/santiago/Library/Caches/uv/builds-v0/.tmp0RSYov/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 (test_uv).
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"]
--- And if I delete both I don't get that error, but the directory |
How do you plan to structure your projects though? I'm just trying to understand your desired project layout and workflow. If you just want the build to work, you can add this to your [tool.hatch.build.targets.wheel]
packages = ["test_uv"] |
In my case the root folder would be called test_uv, and the structure inside of it would look like this for example: .venv In a larger case I would maybe have all my python files structured inside an app folder, for example on a FastAPI microservice, where I would also dockerize the proyect. I don't want to create a package or wheel |
@santigandolfo In this specific case I believe a work around at the moment is to set this in your [tool.hatch.build.targets.wheel]
packages = ["."] |
In my case, I have a
And, for example, when I execute
|
adds dependency to (latest) scapy version omits the regular uv folder structure - testing with proposal of astral-sh/uv#6293
The same thing happens to me. |
You shouldn't need a |
That repository works with uv run fastapi dev app/main.py but there's a trick: in the [project]
name = "app" so you're specifying you need a subfolder named |
Thanks for your answers. I'll tell you a little more, clarifying that I'm new to UV. |
Aside, this would be resolved by #6511. |
@AndreuCodina -- To clarify, this works ( As does this ( Either of these are totally fine. You can also remove the |
I think it's a valid and common layout to have your top-level module be a top-level directory in your project. To pick one example, this is how Django is structured. I would expect
This is the more natural layout, as when you launch the Python repl at the root of the project it can import your module. Imo, additions to the above basic layout should be behind flags. FWIW, I generally make
I currently use Poetry to manage my Python projects (though I now use
That doesn't presume any layout and conveniently lets me specify the author metadata during creation. |
This exists now as of v0.4.0. You can run |
Hi, is there a way to init a uv project without a
src
directory and[build-system]
in thepyproject.toml
?I currently use rye and to do that I create my project with:
But
uv
looks to work differently. When I run:[project]
section in thepyproject.toml
[tool.uv.workspace]
in the pyproject.toml (or else I get the errorerror: No ``project`` table found in: ``/Users/<my_user>/<my_project>/pyproject.toml``
when I runuv sync
)I must do it like this:
The text was updated successfully, but these errors were encountered: