-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow dependency name overriding or elimination #4422
Comments
Thinking about this some more, just the functionality of blocking a dependency from being installed already offers a way to do this kind of override. That is, I could add to my
Then to my
|
Interesting idea! Makes some sense, though I'm also not quite sure how it should be expressed and if it's feasible. |
Another option to express dependency elision is to use the URI version specifier to mean: install this package from nowhere.
The last one was suggested to me by github copilot:
|
And since URIs effectively allow namespacing on schemes, and the definition of the interpretation of schemes is up to whoever introduces them, we could perhaps use schemes to implement the package replacement, e.g:
|
Or, if we want to follow examples of other tools which use prefixed schemes, like
|
Note that |
An alternative that would help me would be to just ignore the sub-dependencies of a package on a per-package basis. That is, instead of having an elision or renaming on my overrides file, I would like to add something like this in my
For reference, such an option has been under discussion for a while in pypa/pip#9948 |
This seems like a reasonable use-case to me. |
I think this would be very useful! At work, we have systems like this for first party packages, but not third party packages. It would make some things less painful if this were the case and unblock some other future use cases. A related lower priority feature request would be the ability to override edges, not just nodes. E.g., if I know one package is overpinning a dependency in a way that I know is safe to override, I might still want to resolve older or error if something else pins it. I don't have strong opinions on syntax. => is a good suggestion, but could be typo-ed. Maybe using
If syntax is controversial, another option is to switch to TOML or something, especially if uv has plans to use such a format somewhere else. |
I realized that this actually is possible today... You can use a never-truthy marker. For example, to remove
|
(This works because with overrides, we just replace all requirements of |
I'm surprised this works, because I'd expect it would result in the resolution being unsolvable... And I'm slightly suspicious of relying on it and it being just accidental behaviour that might be "fixed" in the future... |
@leorochael -- Can you say more about why you would expect that to be unsolvable? I would actually consider it a bug if the resolver failed there, rather than the other way around. |
I might be reading it wrong, but for me an overrides file containing:
Mean:
And if there are packages depending on To me, declaring a constraints override on an uninstallable package is different than declaring a constraints override on a package we're pretending is already installed. |
Ah, but I see where my logic is failing. The constraints override doesn't say: "depend on this uninstallable package". It's saying: "when depending on So, yeah, as long as we add a test for that and document it, then yes, that would already be supported. |
Oh, neat trick! |
## Summary This PR enables users to provide pre-defined static metadata for dependencies. It's intended for situations in which the user depends on a package that does _not_ declare static metadata (e.g., a `setup.py`-only sdist), and that is expensive to build or even cannot be built on some architectures. For example, you might have a Linux-only dependency that can't be built on ARM -- but we need to build that package in order to generate the lockfile. By providing static metadata, the user can instruct uv to avoid building that package at all. For example, to override all `anyio` versions: ```toml [project] name = "project" version = "0.1.0" requires-python = ">=3.12" dependencies = ["anyio"] [[tool.uv.dependency-metadata]] name = "anyio" requires-dist = ["iniconfig"] ``` Or, to override a specific version: ```toml [project] name = "project" version = "0.1.0" requires-python = ">=3.12" dependencies = ["anyio"] [[tool.uv.dependency-metadata]] name = "anyio" version = "3.7.0" requires-dist = ["iniconfig"] ``` The current implementation uses `Metadata23` directly, so we adhere to the exact schema expected internally and defined by the standards. Any entries are treated similarly to overrides, in that we won't even look for `anyio@3.7.0` metadata in the above example. (In a way, this also enables #4422, since you could remove a dependency for a specific package, though it's probably too unwieldy to use in practice, since you'd need to redefine the _rest_ of the metadata, and do that for every package that requires the package you want to omit.) This is under-documented, since I want to get feedback on the core ideas and names involved. Closes #7393.
Neat! However it's giving warnings in recent uv versions: I'd expect a "dependency elimination" to not warn about that. |
Yeah that seems incorrect. I wouldn't expect overrides to throw that warning at all (even if they're not an "elimination") cc @konstin |
While
uv
now has overrides, and issue #2686 is suggesting being able to declare certain overrides as pertaining to a specific dependency, I have an additional suggestion/request.I would like to be able to override a package dependency with a package that has a different name.
As a concrete case, the FuelSDK package depends on
suds-jurko
, but has been tested to work with it's fork/successor projectsuds-community
, a.k.a. justsuds
these days.(Yes, the project has come full circle, with the fork of the fork officially taking over the original name).
A possibility that comes to mind would be a special syntax for the
-o overrides.txt
file like:Or perhaps:
Considering the long history of python packages that fork and continue the work of orphaned packages (e.g. PIL/Pillow), this could be a nice complement to the overrides functionality of uv.
Perhaps it could even be used to remove a dependency completely, e.g.:
suds-jurko=>!
suds-jurko=>
suds-jurko:!
suds-jurko:
The text was updated successfully, but these errors were encountered: