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

Adding a package and pinning to a specific index by name only with uv add #10140

Open
menzenski opened this issue Dec 24, 2024 · 1 comment
Open
Labels
enhancement New feature or improvement to existing functionality

Comments

@menzenski
Copy link

This issue is something of a followup to #6582, which was a duplicate of #171. That issue has comments #171 (comment) and #171 (comment) which seems to be the same thing I am interested in here (but I can't find anything in search that suggests those have been opened as independent issues yet).

Desired Behavior

Given an index definition named my_artifactory in pyproject.toml:

[[tool.uv.index]]
name = "my_artifactory"
url = "https://myorg.jfrog.io/artifactory/api/pypi/pypi/simple"
explicit = true

I would like to be able to run uv add my-private-package --index my_artifactory (or similar command - the important part here is that the CLI command references an index by name only, not by name and URL), with the resulting behavior that the package has been added and pinned to that specific index. Desired output in pyproject.toml:

dependencies = [
    "my-private-package>=0.18.0",
]

[tool.uv.sources]
my-private-package = { index = "my_artifactory" }

Current Workaround

My current workaround is to add the tool.uv.sources entry first, manually in the pyproject.toml file:

[tool.uv.sources]
my-private-package = { index = "my_artifactory" }

Then I can run uv add my-private-package. But I would prefer not to be manually updating pyproject.toml for this - it would be nice to be able to do all "add/update dependency" tasks via the uv CLI.

Comparison to Poetry

I am trying to migrate from Poetry to uv. With Poetry, I can specify an explicit source in pyproject.toml:

[[tool.poetry.source]]
name = "my_artifactory"
url = "https://myorg.jfrog.io/artifactory/api/pypi/pypi/simple"
priority = "explicit"

and add a dependency using poetry add with a --source my_artifactory option, e.g.:

$ poetry add my-private-package --source my_artifactory

The result of this command is a package that is pinned to that specific source:

[tool.poetry.dependencies]
my-private-package = {version = "^0.18.0", source = "my_artifactory"}

I am hoping that the same behavior is possible with uv.

@charliermarsh charliermarsh added the enhancement New feature or improvement to existing functionality label Dec 24, 2024
@charliermarsh
Copy link
Member

I agree that this should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants