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

update rip and rattler #798

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
279 changes: 133 additions & 146 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ insta = { version = "1.34.0", features = ["yaml"] }
is_executable = "1.0.1"
itertools = "0.12.0"
lazy_static = "1.4.0"
miette = { version = "5.10.0", features = ["fancy", "supports-color", "supports-hyperlinks", "supports-unicode", "terminal_size", "textwrap"] }
miette = { version = "7.0.0", features = ["fancy", "supports-color", "supports-hyperlinks", "supports-unicode", "terminal_size", "textwrap"] }
minijinja = { version = "1.0.12", features = ["builtins"] }
once_cell = "1.19.0"
pep440_rs = "0.3.12"
pep508_rs = { version = "0.2.3", features = ["modern"] }
pep440_rs = "0.4.0"
pep508_rs = { version = "0.3.0", features = ["modern"] }
rattler = { version = "0.17.0", default-features = false }
rattler_conda_types = { version = "0.17.0", default-features = false }
rattler_digest = { version = "0.17.0", default-features = false }
Expand All @@ -55,7 +55,7 @@ rattler_virtual_packages = { version = "0.17.0", default-features = false }
regex = "1.10.3"
reqwest = { version = "0.11.23", default-features = false }
reqwest-middleware = "0.2.4"
rip = { package = "rattler_installs_packages", version = "0.5.0", default-features = false }
rip = { package = "rattler_installs_packages", version = "0.7.0", default-features = false }
self-replace = "1.3.7"
serde = "1.0.195"
serde-untagged = "0.1.5"
Expand Down Expand Up @@ -91,15 +91,15 @@ tokio = { version = "1.35.1", features = ["rt"] }
toml = "0.8.8"

[patch.crates-io]
#rattler = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_conda_types = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_digest = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_lock = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_networking = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_repodata_gateway = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_shell = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_solve = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler_virtual_packages = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_conda_types = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_digest = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_lock = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_networking = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_repodata_gateway = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_shell = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_solve = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_virtual_packages = { git = "https://github.com/mamba-org/rattler", branch = "main" }
#rip = { package = "rattler_installs_packages", git = "https://github.com/prefix-dev/rattler_installs_packages", branch = "main" }
#resolvo = { git = "https://github.com/mamba-org/resolvo.git", branch = "main" }
#deno_task_shell = { path = "../deno_task_shell" }
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.73.0
1.75.0
5 changes: 3 additions & 2 deletions src/environment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use miette::{Context, IntoDiagnostic};
use rip::resolve::solve_options::SDistResolution;

use crate::lock_file::{resolve_pypi, LockedCondaPackages, LockedPypiPackages};
use crate::project::virtual_packages::get_minimal_virtual_packages;
Expand Down Expand Up @@ -34,7 +35,7 @@ use rattler_conda_types::{
use rattler_lock::{LockFile, Package, PypiPackageData, PypiPackageEnvironmentData};
use rattler_repodata_gateway::sparse::SparseRepoData;
use reqwest_middleware::ClientWithMiddleware;
use rip::{index::PackageDb, resolve::SDistResolution};
use rip::index::PackageDb;
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -1563,7 +1564,7 @@ async fn spawn_solve_pypi_task(
pb.start();

let result = resolve_pypi(
&package_db,
package_db,
dependencies,
system_requirements,
&repodata_records,
Expand Down
14 changes: 8 additions & 6 deletions src/install_pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use indexmap::IndexSet;
use indicatif::ProgressBar;
use itertools::Itertools;
use miette::{IntoDiagnostic, WrapErr};
use rip::resolve::solve_options::{ResolveOptions, SDistResolution};

use crate::consts::PROJECT_MANIFEST;
use crate::project::manifest::SystemRequirements;
Expand All @@ -22,12 +23,12 @@ use rip::python_env::{
find_distributions_in_venv, uninstall_distribution, Distribution, PythonLocation, WheelTag,
WheelTags,
};
use rip::resolve::{ResolveOptions, SDistResolution};
use rip::types::{
Artifact, ArtifactHashes, ArtifactInfo, ArtifactName, Extra, NormalizedPackageName,
ArtifactHashes, ArtifactInfo, ArtifactName, Extra, HasArtifactName, NormalizedPackageName,
};
use rip::wheel_builder::WheelBuilder;
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;
use std::sync::Arc;
Expand Down Expand Up @@ -302,6 +303,7 @@ fn stream_python_artifacts(
requires_python: pkg_data.requires_python.clone(),
dist_info_metadata: Default::default(),
yanked: Default::default(),
is_direct_url: false,
};

let wheel = tokio::spawn({
Expand All @@ -311,10 +313,10 @@ fn stream_python_artifacts(
let package_db = package_db.clone();
async move {
let wheel_builder = WheelBuilder::new(
&package_db,
&marker_environment,
Some(&compatible_tags),
&resolve_options,
package_db.clone(),
marker_environment,
Some(compatible_tags),
resolve_options.deref().clone(),
HashMap::default(),
)
.into_diagnostic()
Expand Down
8 changes: 4 additions & 4 deletions src/lock_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use miette::IntoDiagnostic;
use rattler_conda_types::{GenericVirtualPackage, MatchSpec, Platform, RepoDataRecord};
use rattler_lock::{LockFile, PackageHashes, PypiPackageData, PypiPackageEnvironmentData};
use rattler_solve::{resolvo, SolverImpl};
use rip::{index::PackageDb, resolve::SDistResolution};
use std::path::Path;
use rip::{index::PackageDb, resolve::solve_options::SDistResolution};
use std::{path::Path, sync::Arc};

use crate::project::manifest::{PyPiRequirement, SystemRequirements};
pub use satisfiability::{
Expand Down Expand Up @@ -41,7 +41,7 @@ pub async fn load_lock_file(project: &Project) -> miette::Result<LockFile> {

#[allow(clippy::too_many_arguments)]
pub async fn resolve_pypi(
package_db: &PackageDb,
package_db: Arc<PackageDb>,
dependencies: IndexMap<rip::types::PackageName, Vec<PyPiRequirement>>,
system_requirements: SystemRequirements,
locked_conda_records: &[RepoDataRecord],
Expand All @@ -54,7 +54,7 @@ pub async fn resolve_pypi(
// Solve python packages
pb.set_message("resolving pypi dependencies");
let python_artifacts = pypi::resolve_dependencies(
package_db,
package_db.clone(),
dependencies,
system_requirements,
platform,
Expand Down
3 changes: 2 additions & 1 deletion src/lock_file/package_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,15 @@ pub enum ConversionError {
Extra(String),
}

impl<'a> From<PypiPackageIdentifier> for PinnedPackage<'a> {
impl From<PypiPackageIdentifier> for PinnedPackage {
fn from(value: PypiPackageIdentifier) -> Self {
PinnedPackage {
name: value.name,
version: value.version,
extras: value.extras,
// We are not aware of artifacts for conda python packages.
artifacts: vec![],
url: None,
tdejager marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
18 changes: 11 additions & 7 deletions src/lock_file/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ use miette::{Context, IntoDiagnostic};
use rattler_conda_types::{Platform, RepoDataRecord};
use rip::index::PackageDb;
use rip::python_env::PythonLocation;
use rip::resolve::{resolve, PinnedPackage, ResolveOptions, SDistResolution};
use rip::resolve::solve_options::{ResolveOptions, SDistResolution};
use rip::resolve::{resolve, PinnedPackage};
use rip::types::PackageName;
use std::path::Path;
use std::sync::Arc;
use std::{collections::HashMap, vec};

/// Resolve python packages for the specified project.
pub async fn resolve_dependencies<'db>(
package_db: &'db PackageDb,
package_db: Arc<PackageDb>,
dependencies: IndexMap<PackageName, Vec<PyPiRequirement>>,
system_requirements: SystemRequirements,
platform: Platform,
conda_packages: &[RepoDataRecord],
python_location: Option<&Path>,
sdist_resolution: SDistResolution,
) -> miette::Result<Vec<PinnedPackage<'db>>> {
) -> miette::Result<Vec<PinnedPackage>> {
if dependencies.is_empty() {
return Ok(vec![]);
}
Expand Down Expand Up @@ -85,22 +87,24 @@ pub async fn resolve_dependencies<'db>(
let mut result = resolve(
package_db,
&requirements,
&marker_environment,
Some(&compatible_tags),
Arc::new(marker_environment),
Some(Arc::new(compatible_tags)),
conda_python_packages
.into_iter()
.map(|p| (p.name.clone(), p))
.collect(),
HashMap::default(),
&ResolveOptions {
ResolveOptions {
sdist_resolution,
python_location,
..Default::default()
},
HashMap::default(),
)
.await
.wrap_err("failed to resolve `pypi-dependencies`, due to underlying error")?;
.unwrap();
// .into_diagnostic()
// .wrap_err("failed to resolve `pypi-dependencies`, due to underlying error")?;

// Remove any conda package from the result
result.retain(|p| !p.artifacts.is_empty());
Expand Down
4 changes: 2 additions & 2 deletions src/project/manifest/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{

impl ProjectManifest {
/// Validate the project manifest.
pub fn validate(&self, source: NamedSource, root_folder: &Path) -> miette::Result<()> {
pub fn validate(&self, source: NamedSource<String>, root_folder: &Path) -> miette::Result<()> {
// Check if the targets are defined for existing platforms
for feature in self.features.values() {
let platforms = feature
Expand Down Expand Up @@ -148,7 +148,7 @@ impl ProjectManifest {

// Create an error report for using a platform that is not supported by the project.
fn create_unsupported_platform_report(
source: NamedSource,
source: NamedSource<String>,
span: Range<usize>,
platform: &Platform,
feature: &Feature,
Expand Down
10 changes: 5 additions & 5 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use rattler_conda_types::{Channel, GenericVirtualPackage, Platform, Version};
use rattler_networking::AuthenticationMiddleware;
use reqwest_middleware::ClientWithMiddleware;
use rip::index::PackageSources;
use rip::{index::PackageDb, normalize_index_url};
use std::hash::Hash;
use std::{
Expand Down Expand Up @@ -140,7 +141,7 @@

/// Returns the source code of the project as [`NamedSource`].
/// Used in error reporting.
pub fn manifest_named_source(&self) -> NamedSource {
pub fn manifest_named_source(&self) -> NamedSource<String> {
NamedSource::new(PROJECT_MANIFEST, self.manifest.contents.clone())
}

Expand Down Expand Up @@ -366,9 +367,9 @@
}

/// Returns the Python index URLs to use for this project.
pub fn pypi_index_urls(&self) -> Vec<Url> {
pub fn pypi_index_url(&self) -> Url {
let index_url = normalize_index_url(Url::parse("https://pypi.org/simple/").unwrap());
vec![index_url]
index_url

Check failure on line 372 in src/project/mod.rs

View workflow job for this annotation

GitHub Actions / Format and Lint

returning the result of a `let` binding from a block
}

/// Returns the package database used for caching python metadata, wheels and more. See the
Expand All @@ -378,11 +379,10 @@
.package_db
.get_or_try_init(|| {
PackageDb::new(
PackageSources::from(self.pypi_index_url()),
self.authenticated_client().clone(),
&self.pypi_index_urls(),
&config::get_cache_dir()?.join("pypi/"),
)
.into_diagnostic()
.map(Arc::new)
})?
.clone())
Expand Down
Loading