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

Treat non-existent site-packages as empty #2413

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion crates/uv-installer/src/site_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions crates/uv/src/commands/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions crates/uv/src/commands/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading