Skip to content

Commit

Permalink
fix: use default indexes if non where given by the lockfile (#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored Aug 26, 2024
1 parent 5e8ae76 commit 00b6f00
Show file tree
Hide file tree
Showing 5 changed files with 1,155 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/install_pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{

use distribution_filename::{DistExtension, ExtensionError, SourceDistExtension, WheelFilename};
use distribution_types::{
BuiltDist, CachedDist, Dist, IndexUrl, InstalledDist, Name, RegistryBuiltDist,
BuiltDist, CachedDist, Dist, IndexLocations, IndexUrl, InstalledDist, Name, RegistryBuiltDist,
RegistryBuiltWheel, RegistrySourceDist, SourceDist, UrlString,
};
use install_wheel_rs::linker::LinkMode;
Expand Down Expand Up @@ -608,7 +608,7 @@ pub async fn update_python_distributions(

let index_locations = pypi_indexes
.map(|indexes| locked_indexes_to_index_locations(indexes, lock_file_dir))
.unwrap()
.unwrap_or_else(|| Ok(IndexLocations::default()))
.into_diagnostic()?;

let registry_client = Arc::new(
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod activation;
pub mod cli;
pub(crate) mod conda_pypi_clobber;
mod environment;
pub mod environment;
mod install_pypi;
mod install_wheel;
mod lock_file;
Expand Down
42 changes: 31 additions & 11 deletions tests/install_tests.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
mod common;

use std::{
fs::{create_dir_all, File},
io::Write,
path::{Path, PathBuf},
str::FromStr,
use crate::common::{
builders::{string_from_iter, HasDependencyConfig, HasPrefixUpdateConfig},
package_database::{Package, PackageDatabase},
};

use common::{LockFileExt, PixiControl};
use pixi::cli::cli_config::ProjectConfig;
use pixi::cli::{run, run::Args, LockFileUsageArgs};
use pixi::environment::LockFileUsage;
use pixi::Project;
use pixi_config::{Config, DetachedEnvironments};
use pixi_consts::consts;
use pixi_manifest::FeatureName;
use rattler_conda_types::Platform;
use serial_test::serial;
use std::{
fs::{create_dir_all, File},
io::Write,
path::{Path, PathBuf},
str::FromStr,
};
use tempfile::TempDir;
use uv_python::PythonEnvironment;

use crate::common::{
builders::{string_from_iter, HasDependencyConfig, HasPrefixUpdateConfig},
package_database::{Package, PackageDatabase},
};

/// Should add a python version to the environment and lock file that matches
/// the specified version and run it
#[tokio::test]
Expand Down Expand Up @@ -565,3 +565,23 @@ async fn test_installer_name() {
let installer = std::fs::read_to_string(installer).unwrap();
assert_eq!(installer, consts::PIXI_UV_INSTALLER);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[serial]
#[cfg_attr(not(feature = "slow_integration_tests"), ignore)]
/// Test full prefix install for an old lock file to see if it still works.
/// Makes sure the lockfile isn't touched and the environment is still installed.
async fn test_old_lock_install() {
let lock_str = std::fs::read_to_string("tests/satisfiability/old_lock_file/pixi.lock").unwrap();
let project = Project::from_path(Path::new(
"tests/satisfiability/old_lock_file/pyproject.toml",
))
.unwrap();
pixi::environment::update_prefix(&project.default_environment(), LockFileUsage::Update, false)
.await
.unwrap();
assert_eq!(
lock_str,
std::fs::read_to_string("tests/satisfiability/old_lock_file/pixi.lock").unwrap()
);
}
Loading

0 comments on commit 00b6f00

Please sign in to comment.