pyenv-binary: handle missing Mach-O install IDs

This commit is contained in:
macayu17 2026-08-30 01:06:39 +05:30
parent b2057155e8
commit 5cd4ea56d2
3 changed files with 9 additions and 4 deletions

View file

@ -43,7 +43,7 @@ if [ "$(uname -s)" = "Darwin" ]; then
local load_commands install_ids rpaths dependency install_id rpath replacement
load_commands="$(otool -L "$file")"
install_ids="$(otool -D "$file")"
install_ids="$(otool -D "$file" 2>/dev/null || true)"
rpaths="$(otool -l "$file")"
install_id="$(printf '%s\n' "$install_ids" | sed -n '2s/^[[:space:]]*//p')"

View file

@ -137,7 +137,7 @@ create_meta() {
create_stub uname 'case "$1" in -s) echo Darwin;; -m) echo arm64;; esac'
create_path_executable install_name_tool true
PATH="${BATS_TEST_TMPDIR}/stubs:${PYENV_TEST_DIR}/bin:/bin" run bash "$out"
PATH="$(path_without otool)" run bash "$out"
assert_failure "pyenv-binary: need otool to relocate the binary"
}
@ -149,7 +149,7 @@ create_meta() {
create_stub uname 'case "$1" in -s) echo Darwin;; -m) echo arm64;; esac'
create_path_executable otool true
PATH="${BATS_TEST_TMPDIR}/stubs:${PYENV_TEST_DIR}/bin:/bin" run bash "$out"
PATH="$(path_without install_name_tool)" run bash "$out"
assert_failure "pyenv-binary: need install_name_tool to relocate the binary"
}
@ -165,6 +165,8 @@ create_meta() {
cp "$archive" "${cache}/Python-3.12.7-binary.tar.gz"
create_stub pyenv 'printf "argc=%s\narg1=%s\narg2=%s\narg3=%s\narg4=%s\n" "$#" "$1" "$2" "$3" "$4"'
create_stub uname 'case "$1" in -s) echo Darwin;; -m) echo arm64;; esac'
create_stub sw_vers 'echo 15.5'
create_stub ldconfig true
create_path_executable otool true
create_path_executable install_name_tool true

View file

@ -66,15 +66,18 @@ case "$1" in
esac
;;
-D )
echo "${file}:"
case "$file" in
*/lib/libpython3.12.dylib )
echo "${file}:"
if [ -n "$OTOOL_RELOCATED" ]; then
echo '@rpath/libpython3.12.dylib'
else
echo "${old}/lib/libpython3.12.dylib"
fi
;;
* )
exit 1
;;
esac
;;
-l )