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 pip compile pyproject.toml ignores dependencies declared in setup.cfg #1624

Closed
SnoopJ opened this issue Feb 18, 2024 · 9 comments · Fixed by #2633
Closed

uv pip compile pyproject.toml ignores dependencies declared in setup.cfg #1624

SnoopJ opened this issue Feb 18, 2024 · 9 comments · Fixed by #2633
Assignees
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool

Comments

@SnoopJ
Copy link

SnoopJ commented Feb 18, 2024

Platform: Ubuntu 20.04
uv version: fef1956

Reproduction

Project files

# pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
# setup.cfg
[options]
packages = find:
install_requires=
    numpy
# setup.py
from setuptools import setup


setup(
    name="dummypkg",
    description="A dummy package",
)

uv invocation

NOTE: this invocation points directly to the uv entrypoint to work around #1623.

$ ~/.pyenv/versions/3.9.16/bin/uv pip compile pyproject.toml  # numpy dependency is ignored
Resolved 0 packages in 4ms
# This file was autogenerated by uv v0.1.4 via the following command:
#    uv pip compile pyproject.toml

Reference pip-compile (7.3.0) invocation

$ pip-compile pyproject.toml
WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras to opt into the new default or use --no-strip-extras to retain the existing behavior.
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
#    pip-compile pyproject.toml
#
numpy==1.26.4
    # via dummypkg (pyproject.toml)
@SnoopJ
Copy link
Author

SnoopJ commented Feb 18, 2024

Note: uv pip install does support this metadata layout, but the inconsistency is quite surprising, and this was the very first issue I ran into with uv.

Moving the dependency declaration into pyproject.toml resolves the problem, but this excludes the setuptools workflow and delivers poorly on a "drop-in" experience.

@zanieb zanieb added bug Something isn't working compatibility Compatibility with a specification or another tool labels Feb 18, 2024
@charliermarsh
Copy link
Member

Thanks, I'll take a look at this. (Right now, we just read the dependency information directly from the pyproject.toml.)

@charliermarsh charliermarsh self-assigned this Feb 22, 2024
@charliermarsh
Copy link
Member

So it looks like pip-tools will actually perform a PEP 517 call when passed a pyproject.toml, to determine the dependencies for the project. That's... interesting. It's a departure from my understanding of how it worked, but we of course have the capability to do that too.

brycedrennan added a commit to brycedrennan/imaginAIry that referenced this issue Mar 6, 2024
waiting for this issue to be resolved before using it for pip-compile

astral-sh/uv#1624
brycedrennan added a commit to brycedrennan/imaginAIry that referenced this issue Mar 6, 2024
waiting for this issue to be resolved before using it for pip-compile

astral-sh/uv#1624

and it didn't properly install the command line tools `aimg` and `imagine` so not using it for editable install on github either
brycedrennan added a commit to brycedrennan/imaginAIry that referenced this issue Mar 6, 2024
waiting for this issue to be resolved before using it for pip-compile

astral-sh/uv#1624

and it didn't properly install the command line tools `aimg` and `imagine` so not using it for editable install on github either
@sbidoul
Copy link

sbidoul commented Mar 10, 2024

This could be solved similarly to #2029.

@zanieb
Copy link
Member

zanieb commented Mar 10, 2024

@sbidoul I don't think so, that issue uses a dynamic value in the pyproject.toml as a hint to reinstall. Here we need to add PEP 517 calls to determine dependencies in some cases (rather than just reading them all directly from the file), but I don't see a key suggesting they're dynamic. Although there is a key in #1644 it doesn't seem to apply in all cases.

@sbidoul
Copy link

sbidoul commented Mar 10, 2024

@zanieb in this case it is the absence of a [project] table that signals that all metadata is dynamic and a PEP 517 metadata preparation is required to obtain it.

@charliermarsh
Copy link
Member

👍 Might be two things here: (1) making it possible to run PEP 517 hooks for these, and (2) adding detection based on whether it’s dynamic.

@charliermarsh
Copy link
Member

I'll be looking into this tomorrow.

@charliermarsh
Copy link
Member

Now in review here: #2633. Expect it to be supported in the next release.

charliermarsh added a commit that referenced this issue Mar 25, 2024
## Summary

When a user passes a `pyproject.toml` to `pip compile` (e.g., `uv pip
compile pyproject.toml`), we extract the requirements from the
`pyproject.toml` directly. However... that isn't always possible (as
seen in the linked issues). When it's _not_, we instead need to run the
PEP 517 build hooks to identify the metadata.

Closes #1624.

Closes #1644.

## Test Plan

`cargo test`
superlucky19971023 added a commit to superlucky19971023/imaginAIry that referenced this issue Aug 18, 2024
waiting for this issue to be resolved before using it for pip-compile

astral-sh/uv#1624

and it didn't properly install the command line tools `aimg` and `imagine` so not using it for editable install on github either
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants