Closed mgaitan closed 1 week ago
Thanks for the writeup!
I'm pretty hesitant, honestly. This results in confusing behavior for users due to the module search path including the package by default. I think we may be better off taking an opinionated stance here.
The lack of flat layout support makes migrating large monorepos (https://github.com/dagster-io/dagster) with dozens of packages much harder.
I agree with your point about the potential confusion with automatic package discovery when using the flat layourt, but there are already thousands of Python projects using it.
I think uv
should prefer the src
layout and use it by default, but at the same time adding support for flat layout seems reasonable to me. The opposite decision will slow down uv
adoption.
@danielgafni Sorry if I'm missing something here, but we just don't create a flat layout in uv init
— as far as I know, uv itself should fully support flat layouts otherwise?
Hey, I first tried using the flat layout and got import errors for our packages.
For example, with the following pyproject.toml
, running
uv pip install -e python_modules/dagster-pipes
passes with both flat and src layout, but only the src layout makes the package available for importing. I'm not sure what can cause this behavior. Moving dagster_pipes
to /src
and re-running uv pip install
solves the problem, that's why I assumed flat layout wasn't supported.
Actually, I can't reproduce this issue anymore :open_mouth: Everything seems to be working, probably something was wrong on my side, sorry about that!
@zanieb I guess my original request have been implemented via uv init --app
right? . We could close this.
Correct! Thanks @mgaitan.
uv init mypackage
currently generates a "src" layout:That's okay as the default because this layout has some known advantages.
However, it isn't a widely used convention, especially for simple, pure Python packages.
So I propose to allow creating a flat layout with
uv init --flat
:Paraphrasing The Hitchhiker's Guide to Python:
and (abusing) the Zen of Python: