Skip to content

Commit

Permalink
fix: git dependencies with recursive git dependencies (prefix-dev#2438)
Browse files Browse the repository at this point in the history
This fixes prefix-dev#2435

---------

Co-authored-by: Ruben Arts <[email protected]>
  • Loading branch information
wolfv and ruben-arts authored Nov 12, 2024
1 parent 5ad9312 commit 9eb2ac2
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 22 deletions.
58 changes: 58 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 22 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ uv-git = { workspace = true }
uv-installer = { workspace = true }
uv-normalize = { workspace = true }
uv-python = { workspace = true }
uv-requirements = { workspace = true }
uv-resolver = { workspace = true }
uv-types = { workspace = true }
xxhash-rust = { workspace = true }
Expand Down Expand Up @@ -355,23 +356,24 @@ reqwest-retry = { git = "https://github.com/TrueLayer/reqwest-middleware", rev =

# Change these lines if you want a patched version of uv
# [patch.'https://github.com/astral-sh/uv']
# pep440_rs = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# pep508_rs = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-build = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-cache = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-client = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-configuration = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-git = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-dispatch = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-distribution = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-installer = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-interpreter = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-normalize = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-resolver = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-types = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# distribution-filename = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# distribution-types = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# install-wheel-rs = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# platform-tags = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# pypi-types = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# requirements-txt = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
# uv-cache = { path = "../uv/crates/uv-cache" }
# uv-pep508 = { path = "../uv/crates/uv-pep508" }
# uv-pep440 = { path = "../uv/crates/uv-pep440" }
# uv-cache-info = { path = "../uv/crates/uv-cache-info" }
# uv-client = { path = "../uv/crates/uv-client" }
# uv-configuration = { path = "../uv/crates/uv-configuration" }
# uv-git = { path = "../uv/crates/uv-git" }
# uv-dispatch = { path = "../uv/crates/uv-dispatch" }
# uv-distribution = { path = "../uv/crates/uv-distribution" }
# uv-installer = { path = "../uv/crates/uv-installer" }
# uv-normalize = { path = "../uv/crates/uv-normalize" }
# uv-resolver = { path = "../uv/crates/uv-resolver" }
# uv-types = { path = "../uv/crates/uv-types" }
# uv-distribution-filename = { path = "../uv/crates/uv-distribution-filename" }
# uv-distribution-types = { path = "../uv/crates/uv-distribution-types" }
# uv-install-wheel = { path = "../uv/crates/uv-install-wheel" }
# uv-platform-tags = { path = "../uv/crates/uv-platform-tags" }
# uv-pypi-types = { path = "../uv/crates/uv-pypi-types" }
# uv-requirements = { path = "../uv/crates/uv-requirements" }
# uv-requirements-txt = { path = "../uv/crates/uv-requirements-txt" }
# uv-python = { path = "../uv/crates/uv-python" }
28 changes: 26 additions & 2 deletions src/lock_file/resolve/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use uv_git::GitResolver;
use uv_install_wheel::linker::LinkMode;
use uv_pypi_types::{HashAlgorithm, HashDigest, RequirementSource};
use uv_python::{Interpreter, PythonEnvironment, PythonVersion};
use uv_requirements::LookaheadResolver;
use uv_resolver::{
AllowedYanks, DefaultResolverProvider, FlatIndex, InMemoryIndex, Manifest, Options, Preference,
Preferences, PythonRequirement, Resolver, ResolverEnvironment,
Expand Down Expand Up @@ -351,16 +352,39 @@ pub async fn resolve_pypi(
.into_diagnostic()?;

let resolver_env = ResolverEnvironment::specific(marker_environment.into());

let constraints = Constraints::from_requirements(constraints.iter().cloned());
let lookahead_index = InMemoryIndex::default();
let lookaheads = LookaheadResolver::new(
&requirements,
&constraints,
&Overrides::default(),
&[],
&context.hash_strategy,
&lookahead_index,
DistributionDatabase::new(
&registry_client,
&build_dispatch,
context.concurrency.downloads,
),
)
.with_reporter(UvReporter::new(
UvReporterOptions::new().with_existing(pb.clone()),
))
.resolve(&resolver_env)
.await
.into_diagnostic()?;

let manifest = Manifest::new(
requirements,
Constraints::from_requirements(constraints.iter().cloned()),
constraints,
Overrides::default(),
Default::default(),
Preferences::from_iter(preferences, &resolver_env),
None,
None,
uv_resolver::Exclusions::None,
Vec::new(),
lookaheads,
);

let interpreter_version = interpreter.python_version();
Expand Down
27 changes: 27 additions & 0 deletions src/uv_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,30 @@ impl uv_resolver::ResolverReporter for UvReporter {

fn on_download_complete(&self, _name: &PackageName, _id: usize) {}
}

impl uv_distribution::Reporter for UvReporter {
fn on_build_start(&self, dist: &BuildableSource) -> usize {
self.start_sync(format!("building {}", dist,))
}

fn on_build_complete(&self, _dist: &BuildableSource, id: usize) {
self.finish(id);
}

fn on_checkout_start(&self, url: &url::Url, _rev: &str) -> usize {
self.start_sync(format!("cloning {}", url))
}

fn on_checkout_complete(&self, _url: &url::Url, _rev: &str, index: usize) {
self.finish(index);
}

// TODO: figure out how to display this nicely
fn on_download_start(&self, _name: &PackageName, _size: Option<u64>) -> usize {
0
}

fn on_download_progress(&self, _id: usize, _bytes: u64) {}

fn on_download_complete(&self, _name: &PackageName, _id: usize) {}
}
12 changes: 12 additions & 0 deletions tests/data/pixi_tomls/pip_git_dep.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
channels = ["conda-forge"]
description = "Package management made easy!"
name = "pixi"
platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]
version = "0.1.0"

[dependencies]
python = "3.12.*"

[pypi-dependencies]
fancycompleter = { git = "https://github.com/bretello/fancycompleter" }
15 changes: 15 additions & 0 deletions tests/integration_python/test_run_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import pytest
from .common import verify_cli_command, ExitCode, default_env_path

ALL_PLATFORMS = '["linux-64", "osx-64", "win-64", "linux-ppc64le", "linux-aarch64"]'
Expand Down Expand Up @@ -153,3 +154,17 @@ def test_prefix_revalidation(pixi: Path, tmp_path: Path, dummy_channel_1: str) -
# Validate that the dummy-a files are reinstalled
for file in dummy_a_meta_files:
assert Path(file).exists()


@pytest.mark.slow
def test_pypi_git_deps(pixi: Path, tmp_path: Path) -> None:
test_data = Path(__file__).parent.parent / "data/pixi_tomls/pip_git_dep.toml"
manifest = tmp_path.joinpath("pixi.toml")
toml = test_data.read_text()
manifest.write_text(toml)

# Run the installation
verify_cli_command(
[pixi, "install", "--manifest-path", manifest],
ExitCode.SUCCESS,
)

0 comments on commit 9eb2ac2

Please sign in to comment.