mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-01 14:31:12 +00:00
Pre-populate authentication sources in Project and Tools APIs (#5367)
## Summary Closes https://github.com/astral-sh/uv/issues/5366.
This commit is contained in:
parent
7908436a76
commit
ada2b2bc29
6 changed files with 44 additions and 2 deletions
|
@ -267,7 +267,6 @@ pub(crate) async fn pip_compile(
|
|||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
|
||||
let client = RegistryClientBuilder::from(client_builder)
|
||||
.cache(cache.clone())
|
||||
.index_urls(index_locations.index_urls())
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use anyhow::{Context, Result};
|
||||
|
||||
use pep508_rs::ExtraName;
|
||||
use uv_auth::store_credentials_from_url;
|
||||
use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode, SetupPyStrategy};
|
||||
|
@ -96,6 +97,11 @@ pub(crate) async fn add(
|
|||
let (tags, markers) =
|
||||
resolution_environment(python_version, python_platform, venv.interpreter())?;
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in settings.index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::from(client_builder)
|
||||
.index_urls(settings.index_locations.index_urls())
|
||||
|
|
|
@ -10,6 +10,7 @@ use tracing::debug;
|
|||
|
||||
use distribution_types::{Diagnostic, UnresolvedRequirementSpecification, VersionId};
|
||||
use pep440_rs::Version;
|
||||
use uv_auth::store_credentials_from_url;
|
||||
use uv_cache::Cache;
|
||||
use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode, Reinstall, SetupPyStrategy};
|
||||
|
@ -236,6 +237,11 @@ pub(super) async fn do_lock(
|
|||
|
||||
let python_requirement = PythonRequirement::from_requires_python(interpreter, &requires_python);
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
|
|
@ -7,6 +7,7 @@ use tracing::debug;
|
|||
use distribution_types::{Resolution, UnresolvedRequirementSpecification};
|
||||
use pep440_rs::Version;
|
||||
use pypi_types::Requirement;
|
||||
use uv_auth::store_credentials_from_url;
|
||||
use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
|
@ -335,6 +336,11 @@ pub(crate) async fn resolve_names(
|
|||
build_options,
|
||||
} = settings;
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
@ -417,6 +423,11 @@ pub(crate) async fn resolve_environment<'a>(
|
|||
let markers = interpreter.markers();
|
||||
let python_requirement = PythonRequirement::from_interpreter(interpreter);
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
@ -539,6 +550,11 @@ pub(crate) async fn sync_environment(
|
|||
let tags = venv.interpreter().tags()?;
|
||||
let markers = venv.interpreter().markers();
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
@ -677,6 +693,11 @@ pub(crate) async fn update_environment(
|
|||
let markers = venv.interpreter().markers();
|
||||
let python_requirement = PythonRequirement::from_interpreter(interpreter);
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use uv_auth::store_credentials_from_url;
|
||||
use uv_cache::Cache;
|
||||
use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
|
@ -166,6 +166,11 @@ pub(super) async fn do_sync(
|
|||
// Read the lockfile.
|
||||
let resolution = lock.to_resolution(project, markers, tags, extras, &dev)?;
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(cache.clone())
|
||||
.native_tls(native_tls)
|
||||
|
|
|
@ -200,6 +200,11 @@ async fn venv_impl(
|
|||
// Extract the interpreter.
|
||||
let interpreter = venv.interpreter();
|
||||
|
||||
// Add all authenticated sources to the cache.
|
||||
for url in index_locations.urls() {
|
||||
store_credentials_from_url(url);
|
||||
}
|
||||
|
||||
// Instantiate a client.
|
||||
let client = RegistryClientBuilder::from(client_builder_clone)
|
||||
.cache(cache.clone())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue