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

Add persistent configuration for non-pip APIs #4294

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

charliermarsh
Copy link
Member

Summary

This PR introduces top-level configuration for uv, such that you can do:

[tool.uv]
index-url = "https://test.pypi.org/simple"

And uv pip compile, uv run, uv tool run, etc., will all respect that configuration.

The settings that were escalated to the top-level remain on tool.uv.pip too, but they're only respected in uv pip commands. If they're specified in both places, then the pip settings win out.

While making this change, I also wired up some of the global options, like connectivity and native_tls, through to all the relevant places.

Closes #4250.

@charliermarsh charliermarsh added configuration Settings and such preview Experimental behavior labels Jun 13, 2024
@charliermarsh charliermarsh force-pushed the charlie/configuration branch 4 times, most recently from b9557c0 to c3ac307 Compare June 13, 2024 01:10
@charliermarsh charliermarsh force-pushed the charlie/configuration branch 2 times, most recently from 59b09d6 to 486ab2f Compare June 13, 2024 01:25
// However, the user-level `tool.uv.pip` settings override the project-level `tool.uv` settings.
// This is awkward, but we merge the user configuration into the workspace configuration, so
// the resulting configuration has both `tool.uv.pip.resolution` (from the user configuration)
// and `tool.uv.resolution` (from the workspace settings), so we choose the former.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really ideal, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little awkward but at least it's consistent, maybe we should warn in that case? Are we going to have more complex merging rules for the pip namespace from the user-level config?

Comment on lines +264 to +287
let client_builder = BaseClientBuilder::new()
.connectivity(connectivity)
.native_tls(native_tls)
.keyring(*keyring_provider);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate, but I wonder if we should have a Settings::as_client_builder or BaseClientBuilder::from_settings

Comment on lines 305 to 333
let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls)
.connectivity(connectivity)
.index_urls(index_locations.index_urls())
.index_strategy(*index_strategy)
.keyring(*keyring_provider)
.markers(markers)
.platform(venv.interpreter().platform())
.platform(interpreter.platform())
.build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so it's on your mind as well as mine, I feel like RegistryClientBuilder should take a BaseClientBuilder instead of duplicating the global options? I found this awkward in some places where I needed to construct both types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I can look at it at some point.

crates/uv/src/settings.rs Outdated Show resolved Hide resolved
@charliermarsh
Copy link
Member Author

@zanieb - Are you cool with this modulo (1) renaming, and (2) removing the From<SyncerArgs> for InstallerOptions impls?

@zanieb
Copy link
Member

zanieb commented Jun 13, 2024

@zanieb - Are you cool with this modulo (1) renaming, and (2) removing the From<SyncerArgs> for InstallerOptions impls?

I think so! It seems pretty reasonable.

Add

Wire up

Split into multiple arguments
@charliermarsh charliermarsh force-pushed the charlie/configuration branch 4 times, most recently from 3e83554 to 99413a4 Compare June 13, 2024 18:58
@charliermarsh
Copy link
Member Author

Okay, I believe I addressed the biggest feedback. I'm saddened by how much boilerplate will be required to add a new setting in the future. Perhaps we can DRY a lot of this up with macros in the future, but it's not my strength.

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@charliermarsh charliermarsh merged commit e0a3890 into main Jun 14, 2024
47 checks passed
@charliermarsh charliermarsh deleted the charlie/configuration branch June 14, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Escalate some tool.uv.pip configuration options to the project API
2 participants