From a7f67e877c5b587e093216959f9f13ddaf74e187 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 17 Jan 2025 14:21:32 -0500 Subject: [PATCH] Avoid attempting to patch macOS dylib for non-macOS installs (#10721) ## Summary For example, `cargo run python install cpython-3.12.8-linux-x86_64_v3-gnu` (on macOS) shouldn't attempt to patch the dylib. At present, it leads to this warning: ``` warning: Failed to patch the install name of the dynamic library for /Users/crmarsh/.local/share/uv/python/cpython-3.12.8-linux-x86_64_v3-gnu/bin/python3.12. This may cause issues when building Python native extensions. Underlying error: Failed to update the install name of the Python dynamic library located at `/Users/crmarsh/.local/share/uv/python/cpython-3.12.8-linux-x86_64_v3-gnu/lib/libpython3.12.dylib` ``` --- crates/uv-python/src/managed.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index 90f2e65de..d7dddab40 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -519,15 +519,17 @@ impl ManagedPythonInstallation { /// See for more information. pub fn ensure_dylib_patched(&self) -> Result<(), macos_dylib::Error> { if cfg!(target_os = "macos") { - if *self.implementation() == ImplementationName::CPython { - let dylib_path = self.python_dir().join("lib").join(format!( - "{}python{}{}{}", - std::env::consts::DLL_PREFIX, - self.key.version().python_version(), - self.key.variant().suffix(), - std::env::consts::DLL_SUFFIX - )); - macos_dylib::patch_dylib_install_name(dylib_path)?; + if self.key().os.is_like_darwin() { + if *self.implementation() == ImplementationName::CPython { + let dylib_path = self.python_dir().join("lib").join(format!( + "{}python{}{}{}", + std::env::consts::DLL_PREFIX, + self.key.version().python_version(), + self.key.variant().suffix(), + std::env::consts::DLL_SUFFIX + )); + macos_dylib::patch_dylib_install_name(dylib_path)?; + } } } Ok(())