From 3928c4d8343d7ced94157fc1369f30a8f9f1f179 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 13 Mar 2024 10:26:47 -0400 Subject: [PATCH 1/2] Treat non-existent site-packages as empty --- crates/uv-dispatch/src/lib.rs | 3 +-- crates/uv-installer/src/site_packages.rs | 16 +++++++++++++++- crates/uv/src/commands/pip_install.rs | 3 +-- crates/uv/src/commands/pip_sync.rs | 3 +-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index 083a87416164..de6821ca157a 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -182,8 +182,7 @@ impl<'a> BuildContext for BuildDispatch<'a> { let tags = self.interpreter.tags()?; // Determine the set of installed packages. - let site_packages = - SitePackages::from_executable(venv).context("Failed to list installed packages")?; + let site_packages = SitePackages::from_executable(venv)?; let Plan { local, diff --git a/crates/uv-installer/src/site_packages.rs b/crates/uv-installer/src/site_packages.rs index 9de913278bb0..ceb430e95e4b 100644 --- a/crates/uv-installer/src/site_packages.rs +++ b/crates/uv-installer/src/site_packages.rs @@ -42,8 +42,22 @@ impl<'a> SitePackages<'a> { let mut by_name = FxHashMap::default(); let mut by_url = FxHashMap::default(); + // Read the site-packages directory. + let site_packages = match fs::read_dir(venv.site_packages()) { + Ok(site_packages) => site_packages, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + return Ok(Self { + venv, + distributions, + by_name, + by_url, + }); + } + Err(err) => return Err(err).context("Failed to read site-packages directory"), + }; + // Index all installed packages by name. - for entry in fs::read_dir(venv.site_packages())? { + for entry in site_packages { let entry = entry?; if entry.file_type()?.is_dir() { let path = entry.path(); diff --git a/crates/uv/src/commands/pip_install.rs b/crates/uv/src/commands/pip_install.rs index 5e3250984131..f98442c0b76c 100644 --- a/crates/uv/src/commands/pip_install.rs +++ b/crates/uv/src/commands/pip_install.rs @@ -143,8 +143,7 @@ pub(crate) async fn pip_install( let _lock = venv.lock()?; // Determine the set of installed packages. - let site_packages = - SitePackages::from_executable(&venv).context("Failed to list installed packages")?; + let site_packages = SitePackages::from_executable(&venv)?; // If the requirements are already satisfied, we're done. Ideally, the resolver would be fast // enough to let us remove this check. But right now, for large environments, it's an order of diff --git a/crates/uv/src/commands/pip_sync.rs b/crates/uv/src/commands/pip_sync.rs index abe755e39266..f073f6478cbd 100644 --- a/crates/uv/src/commands/pip_sync.rs +++ b/crates/uv/src/commands/pip_sync.rs @@ -157,8 +157,7 @@ pub(crate) async fn pip_sync( ); // Determine the set of installed packages. - let site_packages = - SitePackages::from_executable(&venv).context("Failed to list installed packages")?; + let site_packages = SitePackages::from_executable(&venv)?; // Resolve any editables. let resolved_editables = resolve_editables( From 61e6d6c18bf452de692b195701ada981694197d1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 13 Mar 2024 10:28:48 -0400 Subject: [PATCH 2/2] Copy over CentOS test --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95999acf0d87..77742b40bfc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -480,3 +480,32 @@ jobs: - name: "Validate global Python install" shell: bash -el {0} run: python ./scripts/check_system_python.py --uv ./uv + + system-test-amazonlinux: + needs: build-binary-linux + name: "check system | amazonlinux" + runs-on: ubuntu-latest + container: amazonlinux:2023 + steps: + - name: "Install base requirements" + run: | + # Needed for `actions/checkout` + yum install tar gzip which -y + - uses: actions/checkout@v4 + + - name: "Install Python" + run: yum install python3 python3-pip -y + + - name: "Download binary" + uses: actions/download-artifact@v4 + with: + name: uv-linux-${{ github.sha }} + + - name: "Prepare binary" + run: chmod +x ./uv + + - name: "Print Python path" + run: echo $(which python3) + + - name: "Validate global Python install" + run: python3 scripts/check_system_python.py --uv ./uv