Skip to content

Commit

Permalink
wip: trying to debug source path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager committed Dec 5, 2024
1 parent 2a1e115 commit 2114c36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/install_pypi/plan/test/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tempfile::TempDir;
use typed_path::Utf8TypedPathBuf;
use url::Url;
use uv_distribution_filename::WheelFilename;
use uv_distribution_types::{InstalledDirectUrlDist, InstalledDist, InstalledRegistryDist};
use uv_distribution_types::{InstalledDirectUrlDist, InstalledDist, InstalledRegistryDist, Name};
use uv_pypi_types::DirectUrl::VcsUrl;
use uv_pypi_types::{ArchiveInfo, DirectUrl, VcsInfo, VcsKind};

Expand Down Expand Up @@ -195,6 +195,13 @@ impl MockedSitePackages {
self.fake_site_packages.path()
}

pub fn get_installed_dist<S: AsRef<str>>(&self, name: S) -> Option<InstalledDist> {
self.installed_dist
.iter()
.find(|d| d.name().as_str() == name.as_ref())
.cloned()
}

/// Create INSTALLER and METADATA files for the installed dist
/// these are checked for the installer and requires python
fn create_file_backing(
Expand Down Expand Up @@ -436,6 +443,11 @@ impl RequiredPackages {
Self::default()
}

pub fn get_required_dist<S: AsRef<str>>(&self, name: S) -> Option<&PypiPackageData> {
self.required
.get(&uv_normalize::PackageName::new(name.as_ref().to_owned()).unwrap())
}

/// Add a registry package to the required packages
pub fn add_registry<S: AsRef<str>>(mut self, name: S, version: S) -> Self {
let package_name =
Expand Down
13 changes: 12 additions & 1 deletion src/install_pypi/plan/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use self::harness::{InstalledDistOptions, MockedSitePackages, NoCache, RequiredPackages};
use crate::install_pypi::plan::test::harness::{AllCached, TEST_PYTHON_VERSION};
use crate::install_pypi::utils::check_url_freshness;
use crate::install_pypi::NeedReinstall;
use assert_matches::assert_matches;
use url::Url;
Expand Down Expand Up @@ -356,11 +357,21 @@ fn test_local_source_older_than_local_metadata() {
.base_dir()
.join(format!("{}-{}.dist-info", "aiofiles", "0.6.0"))
.join("METADATA");
// Sanity check that these timestamps are different
// Sanity checks that these timestamps are different
assert_ne!(
pyproject.metadata().unwrap().modified().unwrap(),
dist_info.metadata().unwrap().modified().unwrap()
);
let installed_dist = site_packages.get_installed_dist("aiofiles").unwrap();
let required_dist = required.get_required_dist("aiofiles").unwrap();
let location = required_dist
.location
.as_path()
.map(|p| p.to_string())
.map(Url::from_directory_path)
.unwrap()
.unwrap();
assert!(check_url_freshness(&location, &installed_dist).unwrap());

// Install plan should not reinstall anything
let plan = harness::install_planner();
Expand Down

0 comments on commit 2114c36

Please sign in to comment.