Skip to content

Add persistent configuration for non-pip APIs - #4294

Merged
charliermarsh merged 3 commits into
mainfrom
charlie/configuration
Jun 14, 2024
Merged

charliermarsh merged 3 commits into
mainfrom
charlie/configuration

Conversation

@charliermarsh

Copy link
Copy Markdown
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 area: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 requested a review from zanieb June 13, 2024 01:11
@charliermarsh
charliermarsh force-pushed the charlie/configuration branch from c3ac307 to 4df0f77 Compare June 13, 2024 01:15
Comment thread crates/uv-workspace/src/settings.rs Outdated
@charliermarsh
charliermarsh force-pushed the charlie/configuration branch 2 times, most recently from 59b09d6 to 486ab2f Compare June 13, 2024 01:25
Comment thread crates/uv/tests/pip_compile.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
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?

@charliermarsh
charliermarsh force-pushed the charlie/configuration branch from 486ab2f to cfb022a Compare June 13, 2024 01:28
Comment on lines +264 to +287
let client_builder = BaseClientBuilder::new()
.connectivity(connectivity)
.native_tls(native_tls)
.keyring(*keyring_provider);

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread crates/uv/src/commands/project/run.rs Outdated
Comment thread crates/uv/src/settings.rs Outdated
@charliermarsh

Copy link
Copy Markdown
Member Author

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

@zanieb

zanieb commented Jun 13, 2024

Copy link
Copy Markdown
Member

@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
Copy Markdown
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.

@charliermarsh
charliermarsh force-pushed the charlie/configuration branch from 99413a4 to 16de0ce Compare June 13, 2024 19:04
@charliermarsh
charliermarsh force-pushed the charlie/configuration branch from 16de0ce to 164b8e5 Compare June 13, 2024 23:01

@zanieb zanieb left a comment

Copy link
Copy Markdown
Member

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
@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

area: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