Skip to content
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

uv sync removes editable install if [build-system] is not specified #9518

Closed
randolf-scholz opened this issue Nov 29, 2024 · 4 comments
Closed
Labels
question Asking for clarification or support

Comments

@randolf-scholz
Copy link

uv pip install -e .  #
uv lock --upgrade  #
uv sync --upgrade  # ↯ removes main package

It seems this is because if [build-system] is missing, then uv.lock says source = { virtual = "." }, and with it source = { editable = "." }. (see comment by @atomiechen in #1626 (comment)):

The lack of [build-system] should not prevent treating the package as editable. This is consistent with PEP 518 and PyPA specification

Build tools are expected to use the example configuration file above as their default semantics when a pyproject.toml file is not present.

Tools should not require the existence of the [build-system] table. A pyproject.toml file may be used to store configuration details other than build-related data and thus lack a [build-system] table legitimately. If the file exists but is lacking the [build-system] table then the default values as specified above should be used. If the table is specified but is missing required fields then the tool should consider it an error.

Alternatively, if this is not possible, it would make more sense if uv issued a warning/error when attempting to uv pip install -e . a package without [build-system].

@charliermarsh
Copy link
Member

This is intentional. Outside of the uv pip interface, we treat projects without a [build-system] as non-packages: https://docs.astral.sh/uv/concepts/projects/config/#build-systems.

@charliermarsh charliermarsh added the question Asking for clarification or support label Nov 29, 2024
@randolf-scholz
Copy link
Author

uv uses the presence of a build system to determine if a project contains a package that should be installed in the project virtual environment. If a build system is not defined, uv will not attempt to build or install the project itself, just its dependencies. If a build system is defined, uv will build and install the project into the project environment.

But if that is the case, why does the following work?

mkdir myproject && cd myproject
uv init
mkdir -p src/foo
touch src/foo/__init__.py
uv venv --seed
source .venv/bin/activate
uv pip install -e .
python -c "import foo"

@charliermarsh
Copy link
Member

That's a difference between the project APIs (where we use this behavior) and the uv pip CLI (where it would be "breaking" to do so, since it would be a significant divergence from pip).

@zanieb
Copy link
Member

zanieb commented Dec 2, 2024

Notably, uv pip install -e . doesn't really mean anything if you don't want to install the project itself — you'd use uv pip install -r ./pyproject.toml instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

3 participants