Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
542 changes: 281 additions & 261 deletions Cargo.lock

Large diffs are not rendered by default.

63 changes: 32 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,37 +199,38 @@ typed-path = "0.12.0"
unicode-width = "0.2.2"
url = "2.5"
# uv 0.12.10 publishes these internal crates as 0.0.77.
uv-build-frontend = "0.0.90"
uv-cache = "0.0.90"
uv-cache-info = "0.0.90"
uv-cache-key = "0.0.90"
uv-client = "0.0.90"
uv-configuration = "0.0.90"
uv-dispatch = "0.0.90"
uv-distribution = "0.0.90"
uv-distribution-filename = "0.0.90"
uv-distribution-types = "0.0.90"
uv-errors = "0.0.90"
uv-flags = "0.0.90"
uv-fs = "0.0.90"
uv-git = "0.0.90"
uv-git-types = "0.0.90"
uv-install-wheel = "0.0.90"
uv-installer = "0.0.90"
uv-normalize = "0.0.90"
uv-pep440 = "0.0.90"
uv-pep508 = "0.0.90"
uv-platform-tags = "0.0.90"
uv-preview = "0.0.90"
uv-pypi-types = "0.0.90"
uv-python = "0.0.90"
uv-redacted = "0.0.90"
uv-requirements = "0.0.90"
uv-requirements-txt = "0.0.90"
uv-resolver = "0.0.90"
uv-threads = "0.0.90"
uv-types = "0.0.90"
uv-workspace = "0.0.90"
uv-build-frontend = "0.0.95"
uv-cache = "0.0.95"
uv-cache-info = "0.0.95"
uv-cache-key = "0.0.95"
uv-client = "0.0.95"
uv-configuration = "0.0.95"
uv-dispatch = "0.0.95"
uv-distribution = "0.0.95"
uv-distribution-filename = "0.0.95"
uv-distribution-types = "0.0.95"
uv-errors = "0.0.95"
uv-flags = "0.0.95"
uv-fs = "0.0.95"
uv-git = "0.0.95"
uv-git-types = "0.0.95"
uv-install-wheel = "0.0.95"
uv-installer = "0.0.95"
uv-normalize = "0.0.95"
uv-pep440 = "0.0.95"
uv-pep508 = "0.0.95"
uv-platform-tags = "0.0.95"
uv-preview = "0.0.95"
uv-pypi-types = "0.0.95"
uv-python-interpreter = "0.0.95"
uv-redacted = "0.0.95"
uv-requirements = "0.0.95"
uv-requirements-txt = "0.0.95"
uv-resolver = "0.0.95"
uv-static = "0.0.95"
uv-threads = "0.0.95"
uv-types = "0.0.95"
uv-workspace = "0.0.95"
webpki-root-certs = "1"
which = "8.0.0"
xxhash-rust = "0.8.15"
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ url = { workspace = true }
uv-cache = { workspace = true }
uv-installer = { workspace = true }
uv-normalize = { workspace = true }
uv-python = { workspace = true }
uv-python-interpreter = { workspace = true }
uv-threads = { workspace = true }
zip = { workspace = true }

Expand Down
6 changes: 3 additions & 3 deletions crates/pixi/tests/integration_rust/install_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tempfile::{TempDir, tempdir};
use tokio::{fs, task::JoinSet};
use url::Url;
use uv_normalize::PackageName;
use uv_python::PythonEnvironment;
use uv_python_interpreter::PythonEnvironment;
use uv_threads::initialize_rayon_once;

use crate::common::pypi_index::PyPIPackage;
Expand Down Expand Up @@ -345,8 +345,8 @@ fn create_uv_environment(prefix: &Path, cache: &uv_cache::Cache) -> PythonEnviro
};

// Current interpreter and venv
let interpreter = uv_python::Interpreter::query(python, cache).unwrap();
uv_python::PythonEnvironment::from_interpreter(interpreter)
let interpreter = uv_python_interpreter::Interpreter::query(python, cache).unwrap();
uv_python_interpreter::PythonEnvironment::from_interpreter(interpreter)
}

// Helper to check if a pypi package is installed.
Expand Down
1 change: 1 addition & 0 deletions crates/pixi_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ uv-distribution-filename = { workspace = true }
uv-distribution-types = { workspace = true }
uv-normalize = { workspace = true }
uv-pep508 = { workspace = true }
uv-redacted = { workspace = true }
uv-types = { workspace = true }

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion crates/pixi_api/src/workspace/list/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use uv_distribution::RegistryWheelIndex;
use uv_distribution_filename::WheelFilename;
use uv_distribution_types::IndexUrl;
use uv_pep508::VerbatimUrl;
use uv_redacted::SafeUrl;

#[derive(Debug, Clone, Serialize)]
pub struct Package {
Expand Down Expand Up @@ -87,7 +88,7 @@ impl Package {
.index_url
.clone()
.unwrap_or_else(|| consts::DEFAULT_PYPI_INDEX_URL.clone());
let index = IndexUrl::from(VerbatimUrl::from(url));
let index = IndexUrl::from(VerbatimUrl::from(SafeUrl::from_url(url)));
let size = if let Some(registry_index) = registry_index {
// Handle case where the registry index is present
let wheel_filename = p
Expand Down
3 changes: 2 additions & 1 deletion crates/pixi_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ uv-pep440 = { workspace = true }
uv-pep508 = { workspace = true }
uv-preview = { workspace = true }
uv-pypi-types = { workspace = true }
uv-python = { workspace = true }
uv-python-interpreter = { workspace = true }
uv-redacted = { workspace = true }
uv-requirements = { workspace = true }
uv-requirements-txt = { workspace = true }
uv-resolver = { workspace = true }
uv-static = { workspace = true }
uv-threads = { workspace = true }
uv-types = { workspace = true }
uv-workspace = { workspace = true }
Expand Down
34 changes: 22 additions & 12 deletions crates/pixi_core/src/lock_file/resolve/build_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use uv_distribution_types::{
};
use uv_distribution_types::{ExtraBuildVariables, Requirement};
use uv_install_wheel::LinkMode;
use uv_python::{Interpreter, InterpreterError, PythonEnvironment};
use uv_python_interpreter::{Interpreter, InterpreterError, PythonEnvironment};
use uv_resolver::{ExcludeNewer, FlatIndex};
use uv_types::{BuildArena, BuildContext, BuildStack, HashStrategy, ResolvedRequirements};
use uv_workspace::WorkspaceCache;
Expand Down Expand Up @@ -292,7 +292,7 @@ pub enum LazyBuildDispatchError {
#[error(transparent)]
ConversionError(#[from] pixi_uv_conversions::ConversionError),
#[error(transparent)]
Uv(#[from] BuildDispatchError),
Uv(Box<BuildDispatchError>),
#[error(transparent)]
UvFrontend(#[from] uv_build_frontend::Error),
#[error("failed to query interpreter in instantiated prefix")]
Expand All @@ -303,6 +303,12 @@ pub enum LazyBuildDispatchError {
PythonMissingError { prefix: String },
}

impl From<BuildDispatchError> for LazyBuildDispatchError {
fn from(err: BuildDispatchError) -> Self {
Self::Uv(Box::new(err))
}
}

impl uv_errors::Hinted for LazyBuildDispatchError {}

impl IsBuildBackendError for LazyBuildDispatchError {
Expand Down Expand Up @@ -492,7 +498,13 @@ impl<'a> LazyBuildDispatch<'a> {
impl BuildContext for LazyBuildDispatch<'_> {
type SourceDistBuilder = SourceBuild;

async fn interpreter(&self) -> &uv_python::Interpreter {
fn tar_backend(&self) -> uv_static::TarBackend {
// Matches what `BuildDispatch::new` selects, without forcing
// initialization of the lazy dispatch.
uv_static::TarBackend::from_env()
}

async fn interpreter(&self) -> &uv_python_interpreter::Interpreter {
// In most cases the interpreter should be initialized, because one of the other
// trait methods will have been called
// But in case it is not, we will initialize it here
Expand Down Expand Up @@ -546,16 +558,17 @@ impl BuildContext for LazyBuildDispatch<'_> {
async fn resolve<'a>(
&'a self,
requirements: &'a [Requirement],
hash_override: Option<&'a HashStrategy>,
build_stack: &'a BuildStack,
) -> Result<ResolvedRequirements, impl IsBuildBackendError> {
// Box the inner uv future. uv re-enters this trait recursively when an
// sdist needs its build backend resolved (`process_request → setup_build
// → resolve → install → process_request`), so flattening the
// state machine here keeps the cumulative stack frame bounded.
let dispatch = self.get_or_try_init().await?;
Box::pin(dispatch.resolve(requirements, build_stack))
Box::pin(dispatch.resolve(requirements, hash_override, build_stack))
.await
.map_err(LazyBuildDispatchError::Uv)
.map_err(LazyBuildDispatchError::from)
}

async fn install<'a>(
Expand All @@ -567,7 +580,7 @@ impl BuildContext for LazyBuildDispatch<'_> {
let dispatch = self.get_or_try_init().await?;
Box::pin(dispatch.install(resolution, venv, build_stack))
.await
.map_err(LazyBuildDispatchError::Uv)
.map_err(LazyBuildDispatchError::from)
}

async fn setup_build<'a>(
Expand Down Expand Up @@ -638,15 +651,13 @@ impl BuildContext for LazyBuildDispatch<'_> {
fn config_settings_package(&self) -> &uv_distribution_types::PackageConfigSettings {
self.lazy_deps
.package_config_settings
.get()
.expect("package config settings not initialized, this is a programming error")
.get_or_init(|| self.params.package_config_settings.clone())
}

fn extra_build_requires(&self) -> &uv_distribution_types::ExtraBuildRequires {
self.lazy_deps
.extra_build_requires
.get()
.expect("extra build requires not initialized, this is a programming error")
.get_or_init(|| self.params.extra_build_requires.clone())
}

fn build_isolation(&self) -> uv_types::BuildIsolation<'_> {
Expand All @@ -661,7 +672,6 @@ impl BuildContext for LazyBuildDispatch<'_> {
fn extra_build_variables(&self) -> &ExtraBuildVariables {
self.lazy_deps
.extra_build_variables
.get()
.expect("extra build variables not initialized, this is a programming error")
.get_or_init(|| self.params.extra_build_variables.clone())
}
}
9 changes: 4 additions & 5 deletions crates/pixi_core/src/lock_file/resolve/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ pub async fn resolve_pypi(
let uv_reference = into_uv_git_reference(pixi_git_ref);
let uv_sha = into_uv_git_sha(pinned_git_spec.source.commit);

let display_safe_url =
uv_redacted::DisplaySafeUrl::from_url(pinned_git_spec.git.clone());
let display_safe_url = uv_redacted::SafeUrl::from_url(pinned_git_spec.git.clone());

let repository_url = RepositoryUrl::new(display_safe_url);
let reference = RepositoryReference {
Expand Down Expand Up @@ -654,7 +653,7 @@ pub async fn resolve_pypi(
// The BuildDispatch might resolve or install when building wheels which will be
// mostly with build isolation. In that case we want to use fresh
// non-tampered requests.
.with_shared_state(context.shared_state.fork())
.with_shared_state(context.shared_state.fork().into_inner())
.with_no_sources(context.no_sources.clone())
.with_concurrency(context.concurrency.clone())
.with_link_mode(link_mode)
Expand Down Expand Up @@ -1158,7 +1157,7 @@ async fn lock_pypi_packages(
metadata,
url_or_path,
hash,
Some((*best_wheel.index).clone()),
Some((*best_wheel.index).clone().into_unsafe_url()),
)?);
}
BuiltDist::DirectUrl(dist) => {
Expand Down Expand Up @@ -1254,7 +1253,7 @@ async fn lock_pypi_packages(
get_url_or_path(&reg.index, &reg.file.url, abs_project_root)
.map_err(LockPypiPackagesError::RegistrySdistLocation)?,
hash,
Some((*reg.index).clone()),
Some((*reg.index).clone().into_unsafe_url()),
&anchor,
)?);
}
Expand Down
23 changes: 16 additions & 7 deletions crates/pixi_core/src/lock_file/resolve/resolver_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use pixi_record::PixiRecord;
use uv_distribution::{ArchiveMetadata, Metadata};
use uv_distribution_filename::SourceDistExtension;
use uv_distribution_types::{
Dist, File, FileLocation, HashComparison, IndexUrl, PrioritizedDist, RegistrySourceDist,
SourceDist, SourceDistCompatibility, UrlString,
Dist, File, FileLocation, IndexUrl, RegistrySourceDist, SourceDist, UrlString,
};
use uv_redacted::DisplaySafeUrl;
use uv_redacted::{SafeUrl, policy::Stripped};
use uv_resolver::{
DefaultResolverProvider, FlatDistributions, MetadataResponse, ResolverProvider, VersionMap,
VersionsResponse, WheelMetadataResult,
DefaultResolverProvider, FlatDistributions, HashComparison, MetadataResponse, PrioritizedDist,
ResolverProvider, SourceDistCompatibility, VariantsJsonResponse, VersionMap, VersionsResponse,
WheelMetadataResult,
};
use uv_types::BuildContext;

Expand Down Expand Up @@ -66,7 +66,7 @@ impl<Context: BuildContext> ResolverProvider for CondaResolverProvider<'_, Conte
upload_time_utc_ms: None,
url: match repodata_record {
PixiRecord::Binary(repodata_record) => FileLocation::AbsoluteUrl(
UrlString::from(DisplaySafeUrl::from_url(repodata_record.url.clone())),
UrlString::from(SafeUrl::from_url(repodata_record.url.clone())),
),
PixiRecord::Source(_source) => {
// TODO(baszalmstra): Does this matter??
Expand All @@ -82,7 +82,7 @@ impl<Context: BuildContext> ResolverProvider for CondaResolverProvider<'_, Conte
version: version.parse().expect("could not convert to pypi version"),
file: Box::new(file),
index: IndexUrl::Pypi(Arc::new(uv_pep508::VerbatimUrl::from_url(
DisplaySafeUrl::from_url(consts::DEFAULT_PYPI_INDEX_URL.clone()),
SafeUrl::from_url(consts::DEFAULT_PYPI_INDEX_URL.clone()).with_policy(Stripped),
))),
wheels: vec![],
size_is_authoritative: false,
Expand Down Expand Up @@ -180,4 +180,13 @@ impl<Context: BuildContext> ResolverProvider for CondaResolverProvider<'_, Conte
) -> impl Future<Output = WheelMetadataResult> + 'io {
self.fallback.get_installed_metadata(dist)
}

fn fetch_variants_json<'io>(
&'io self,
package_name: &'io uv_normalize::PackageName,
file: &'io File,
index: &'io IndexUrl,
) -> impl Future<Output = Result<VariantsJsonResponse, uv_client::Error>> + 'io {
self.fallback.fetch_variants_json(package_name, file, index)
}
}
15 changes: 8 additions & 7 deletions crates/pixi_core/src/lock_file/satisfiability/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
str::FromStr,
sync::{Arc, Mutex},
};
use uv_redacted::DisplaySafeUrl;
use uv_redacted::SafeUrl;

use dashmap::DashMap;
use futures::TryStreamExt;
Expand Down Expand Up @@ -191,7 +191,7 @@ pub(crate) fn pypi_satisfies_requirement(
locked_data.as_wheel().and_then(|w| w.index_url.as_ref()),
) {
(Some(required_index), Some(locked_url)) => {
let required_url: Url = required_index.url.url().clone().into();
let required_url = required_index.url.url().clone().into_unsafe_url();
// When a package is resolved from a local directory / file:// index,
// rattler_lock stores its location as a Path and strips index_url during
// deserialization (defaulting it to default_index). If the locked package
Expand Down Expand Up @@ -268,7 +268,7 @@ pub(crate) fn pypi_satisfies_requirement(
.strip_prefix("direct+")
.and_then(|str| Url::parse(str).ok())
.unwrap_or(locked_url.clone());
let locked_url = DisplaySafeUrl::from_url(locked_url);
let locked_url = SafeUrl::from_url(locked_url);

// Compare the URLs ignoring any userinfo (credentials). We redact
// credentials (e.g. `__token__` -> `****`) when writing the direct
Expand Down Expand Up @@ -304,7 +304,8 @@ pub(crate) fn pypi_satisfies_requirement(
if let Ok(pinned_git_spec) = LockedGitUrl::new(url.clone()).to_pinned_git_spec()
{
let pinned_repository = RepositoryUrl::new(&pinned_git_spec.git);
let specified_repository = RepositoryUrl::new(git_url);
let specified_repository =
RepositoryUrl::new(&git_url.clone().into_unsafe_url());

let repo_is_same = pinned_repository == specified_repository;
if !repo_is_same {
Expand Down Expand Up @@ -727,7 +728,7 @@ async fn read_local_package_metadata(
.with_index_strategy(index_strategy)
.with_capabilities(ctx.uv_context.capabilities.clone())
.with_workspace_cache(ctx.uv_context.workspace_cache.clone())
.with_shared_state(ctx.uv_context.shared_state.fork())
.with_shared_state(ctx.uv_context.shared_state.fork().into_inner())
.with_no_sources(ctx.uv_context.no_sources.clone())
.with_concurrency(ctx.uv_context.concurrency.clone())
.with_cache_config_settings(&cache_config_settings);
Expand Down Expand Up @@ -884,7 +885,7 @@ mod tests {
use rattler_lock::{PypiPackageData, UrlOrPath, Verbatim};
use url::Url;
use uv_distribution_types::RequirementSource;
use uv_redacted::DisplaySafeUrl;
use uv_redacted::SafeUrl;

use super::super::platform::RequirementOrigin;
use super::super::{PlatformUnsat, PypiNoBuildCheck};
Expand Down Expand Up @@ -1540,7 +1541,7 @@ mod tests {

let index =
uv_distribution_types::IndexMetadata::from(uv_distribution_types::IndexUrl::from(
uv_pep508::VerbatimUrl::from_url(DisplaySafeUrl::parse(index_url).unwrap()),
uv_pep508::VerbatimUrl::from_url(SafeUrl::parse(index_url).unwrap()),
));
uv_distribution_types::Requirement {
name: UvPackageName::from_str(name).unwrap(),
Expand Down
Loading
Loading