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

Editable installation with extras #7845

Open
detlefla opened this issue Oct 1, 2024 · 8 comments
Open

Editable installation with extras #7845

detlefla opened this issue Oct 1, 2024 · 8 comments
Labels
documentation Improvements or additions to documentation question Asking for clarification or support

Comments

@detlefla
Copy link

detlefla commented Oct 1, 2024

When I try to install extras for an editable installation, e.g. uv pip install -e . --all-extras, uv refuses this with an error message:

error: Requesting extras requires a `pyproject.toml`, `setup.cfg`, or `setup.py` file.

Without --extra or ´--all-extras` everything is fine, so the pyproject.toml file is obviously present and can be processed.

Particularly with an install -e, however, it's often desirable to install the dev dependencies; uv pip install doesn't have any kind of --dev flag (unless I miss something).

I haven't provided a full working sample as I think this behaviour doesn't depend on any particular conditions, but of course I'll try to prepare a stripped-down sample if it helps. I'm using uv 0.4.17.

@notatallshaw-gts
Copy link

Don't you want uv pip install -e .[my-extra]?

That's how it works for pip, and I believe uv is copying the behavior here.

@detlefla
Copy link
Author

detlefla commented Oct 1, 2024

OK, thanks for pointing this out, in fact it works. It's a bit surprising that --all-extras doesn't work then, and it seems that an extra [dev] is apparently better suited for development than using tool.uv.dev-dependencies.

But I can very well live with that, thank you for doing a great job with uv.

@notatallshaw-gts
Copy link

It's a bit surprising that --all-extras doesn't work then

--all-extras isn't an option from pip, it's an option from pip-compile, so while I'm sure that uv could add it, it's behavior is not currently defined, e.g. would you wanting it installing every extra from every transitive dependency?

@detlefla
Copy link
Author

detlefla commented Oct 1, 2024

As this option appears in the output for uv pip install --help and this output looks significantly different from uv pip compile --help, I thought this option was related to the install subcommand.

In fact IMO it wouldn't be useful to apply this to all transitive dependencies, no.

@notatallshaw-gts
Copy link

notatallshaw-gts commented Oct 1, 2024

As this option appears in the output for uv pip install --help

Yeah:

$ uv pip install --help | grep "all-extras"
      --all-extras                           Include all optional dependencies

$ ls pyproject.toml
pyproject.toml

$ uv pip install . --all-extras
error: Requesting extras requires a `pyproject.toml`, `setup.cfg`, or `setup.py` file.

This looks like a bug, --all-extras should not be available for uv pip install? Or the docs / error message isn't clear when it should work? @charliermarsh ?

@charliermarsh
Copy link
Member

--all-extras applies to passing a pyproject.toml or similar directly -- like uv pip install ./pyproject.toml --all-extras. There's no defined syntax for enabling extras there, unlike when passing a path (uv pip install .[dev]).

@notatallshaw-gts
Copy link

That makes sense, the --help and the error are both pretty unclear though if you're not already familiar with that exact use case.

If no one else does I might write a PR, or else I will be confused when I come across this again in a years time.

@zanieb zanieb added documentation Improvements or additions to documentation question Asking for clarification or support labels Oct 1, 2024
@pamelafox
Copy link

I was just writing up a similar experience when I found this one. What I wrote up--

I attempted to install a project that had a pyproject.toml in the root and several extras defined:

(flask-admin) flask-admin % uv pip install -e . --all-extras                  
error: Requesting extras requires a `pyproject.toml`, `setup.cfg`, or `setup.py` file.

It worked when I ran:

(flask-admin) flask-admin % uv pip install -e . --all-extras -r pyproject.toml

It seemed unnecessary, since -e . works fine when not specifying extras, so I was surprised I needed to explicitly pass in the pyproject.toml when asking for extras.

I think another example in the documentation could be helpful. I was looking through https://docs.astral.sh/uv/pip/packages/#editable-packages for guidance.

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

No branches or pull requests

5 participants