Skip to content

Commit

Permalink
Run tests on Windows 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 7, 2024
1 parent b061db0 commit cfa6c73
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
# For Ubuntu and Windows, this requires Organization-level configuration
# See: https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/about-larger-runners#about-ubuntu-and-windows-larger-runners
- { os: "ubuntu", runner: "ubuntu-latest-large" }
- { os: "windows", runner: "windows-latest-large" }
- { os: "windows", runner: "windows-2019" }
- { os: "macos", runner: "macos-14" }
fail-fast: false
runs-on:
Expand Down Expand Up @@ -82,6 +82,10 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: "Cargo build"
run: cargo build
- name: "Do thing"
run: ./target/debug/uv venv && ./target/debug/uv pip install lxml && ./target/debug/uv pip uninstall lxml && ./target/debug/uv pip install lxml
- name: "Cargo test"
run: |
cargo nextest run --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 12 --final-status-level slow
Expand Down
8 changes: 8 additions & 0 deletions crates/distribution-types/src/installed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ impl InstalledDist {

/// Read the `METADATA` file from a `.dist-info` directory.
pub fn metadata(&self) -> Result<pypi_types::Metadata21> {
// Print the path.
println!("path: {}", self.path().simplified_display());
// Print everything in the path:
for entry in fs::read_dir(self.path())? {
let entry = entry?;
println!("entry: {}", entry.path().simplified_display());
}

let path = self.path().join("METADATA");
let contents = fs::read(&path)?;
pypi_types::Metadata21::parse(&contents).with_context(|| {
Expand Down
29 changes: 23 additions & 6 deletions crates/install-wheel-rs/src/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use std::collections::BTreeSet;
use std::path::{Component, Path, PathBuf};

use fs_err as fs;
use rustc_hash::FxHashSet;
use tracing::debug;
use uv_fs::Simplified;

use crate::wheel::read_record_file;
use crate::Error;
Expand Down Expand Up @@ -31,21 +33,24 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {

// Uninstall the files, keeping track of any directories that are left empty.
let mut visited = BTreeSet::new();
let mut deleted = FxHashSet::default();
for entry in &record {
let path = site_packages.join(&entry.path);
match fs::remove_file(&path) {
Ok(()) => {
debug!("Removed file: {}", path.display());
println!("Removed file: {}", path.display());
file_count += 1;
deleted.insert(normalize_path(&path));
if let Some(parent) = path.parent() {
visited.insert(normalize_path(parent));
}
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(err) => match fs::remove_dir_all(&path) {
Ok(()) => {
debug!("Removed directory: {}", path.display());
println!("Removed directory: {}", path.display());
dir_count += 1;
deleted.insert(normalize_path(&path));
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(_) => return Err(err.into()),
Expand Down Expand Up @@ -77,8 +82,9 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {
let pycache = path.join("__pycache__");
match fs::remove_dir_all(&pycache) {
Ok(()) => {
debug!("Removed directory: {}", pycache.display());
println!("Removed directory: {}", pycache.display());
dir_count += 1;
deleted.insert(normalize_path(path));
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(err) => return Err(err.into()),
Expand All @@ -92,15 +98,26 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {
Err(err) => return Err(err.into()),
};

// Ignore files that were deleted.
let mut entries = read_dir.filter(|entry| {
let Ok(entry) = entry else {
return false;
};
let is_deleted = deleted.contains(&normalize_path(&entry.path()));
println!("entry is deleted: {} : {}", entry.path().simplified_display(), is_deleted);
is_deleted
});

// If the directory is not empty, we're done.
if read_dir.next().is_some() {
if entries.next().is_some() {
break;
}

fs::remove_dir(path)?;
fs::remove_dir_all(path)?;

debug!("Removed directory: {}", path.display());
println!("Removed directory: {}", path.display());
dir_count += 1;
deleted.insert(normalize_path(path));

if let Some(parent) = path.parent() {
path = parent;
Expand Down

0 comments on commit cfa6c73

Please sign in to comment.