Skip to content

Force uv to skip certain (transitive) dependencies #9174

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

Closed
chrisfougner opened this issue Nov 17, 2024 · 5 comments
Closed

Force uv to skip certain (transitive) dependencies #9174

chrisfougner opened this issue Nov 17, 2024 · 5 comments

Comments

@chrisfougner
Copy link

Is there a way to force uv to skip certain dependencies? Specifically we use docker containers maintained by Nvidia, which come pre-installed with various python ML packages on the system level (torch, apex, amp_C, flash-attn). If I use uv venv --system-site-packages then I can access those dependencies, the problem is that if any package that I install has a transitive dependency on one of these packages (primarily torch), then the one installed in venv will be chosen over the system one, and things break. I'd like to be able to specify that torch for example should not be installed as a transitive dependency, but I'm not sure how to do this.

@danielhollas
Copy link
Contributor

It would be great to have a proper solution for this, not just a hack. We have a similar situation in our container setup, but the number of packages much larger.

See also discussion in #2500

@charliermarsh
Copy link
Member

I think using overrides with an "impossible" marker is actually kind of a fine solution? The alternative is that we introduce something non-standard.

@charliermarsh
Copy link
Member

I think this should be tracked in #4422 though.

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@chrisfougner
Copy link
Author

Thank you both. Super helpful. The solution seems fine to me.

For anyone else that stubmless upon this issue. Add the following to your pyproject.toml. If you have a top-level pyproject.toml and any additional package specific ones, you should add it to the top-level pyproject.toml

[tool.uv]
override-dependencies = [
    "torch; sys_platform == 'never'",
]

@danielhollas
Copy link
Contributor

I would just note that this is quite a dangerous solution to the original problem, since if a package depends on a torch version that is not satisfied by the underlying environment this will result in a broken installation.

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

No branches or pull requests

3 participants