From d560da9813cdbb75def8f9d310884d2d276131ed Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 1 Jul 2025 15:30:52 -0700 Subject: [PATCH 1/7] Add tests for darwin cryptography linking --- tests/test_verify_build.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_verify_build.py b/tests/test_verify_build.py index 47bbed12..e08aa612 100644 --- a/tests/test_verify_build.py +++ b/tests/test_verify_build.py @@ -835,6 +835,39 @@ def find_library(path, search): assert valid, p.stdout.decode() +@pytest.mark.skip_unless_on_darwin +@pytest.mark.parametrize("cryptography_version", ["42.0.5", "40.0.1"]) +def test_cryptography_rpath_darwin(pipexec, build, minor_version, cryptography_version): + #def find_library(path, search): + # for root, dirs, files in os.walk(path): + # for fname in files: + # if fname.startswith(search) and fname.endswith(".so"): + # return fname + + env = os.environ.copy() + env["RELENV_BUILDENV"] = "yes" + env["OPENSSL_DIR"] = f"{build}" + p = subprocess.run( + [ + str(pipexec), + "install", + f"cryptography=={cryptography_version}", + "--no-cache-dir", + "--no-binary=cryptography", + ], + env=env, + ) + assert p.returncode != 1, "Failed to pip install cryptography" + p = subprocess.run([ + "otool", + "-L", + f"{build}/lib/python{minor_version}/site-packages/cryptography/hazmat/bindings/_rust.abi3.so", + capture_output=True, + ] + + assert False, (p.stdout.decode(), p.stderr.decode()) + + @pytest.mark.skip_unless_on_linux def test_install_pycurl(pipexec, build): _install_ppbt(pipexec) From 4c72ed955166c0a41133313895973b196f77fafb Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 1 Jul 2025 15:48:40 -0700 Subject: [PATCH 2/7] Run relocate on darwin wheel installs --- relenv/runtime.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/relenv/runtime.py b/relenv/runtime.py index e2beca11..e2e1e9b4 100644 --- a/relenv/runtime.py +++ b/relenv/runtime.py @@ -336,6 +336,8 @@ def wrapper( if relocate().is_elf(file): debug(f"Relenv - Found elf {file}") relocate().handle_elf(plat / file, rootdir / "lib", True, rootdir) + elif relocate().is_macho(file): + relocate().handle_macho(plat / file, rootdir, True) return wrapper From b565517502b78c0ea82c3e80ac9a46213d4ab126 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 1 Jul 2025 15:51:00 -0700 Subject: [PATCH 3/7] Fix syntax wart --- tests/test_verify_build.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_verify_build.py b/tests/test_verify_build.py index e08aa612..816da62a 100644 --- a/tests/test_verify_build.py +++ b/tests/test_verify_build.py @@ -838,7 +838,7 @@ def find_library(path, search): @pytest.mark.skip_unless_on_darwin @pytest.mark.parametrize("cryptography_version", ["42.0.5", "40.0.1"]) def test_cryptography_rpath_darwin(pipexec, build, minor_version, cryptography_version): - #def find_library(path, search): + # def find_library(path, search): # for root, dirs, files in os.walk(path): # for fname in files: # if fname.startswith(search) and fname.endswith(".so"): @@ -858,12 +858,14 @@ def test_cryptography_rpath_darwin(pipexec, build, minor_version, cryptography_v env=env, ) assert p.returncode != 1, "Failed to pip install cryptography" - p = subprocess.run([ - "otool", - "-L", - f"{build}/lib/python{minor_version}/site-packages/cryptography/hazmat/bindings/_rust.abi3.so", + p = subprocess.run( + [ + "otool", + "-L", + f"{build}/lib/python{minor_version}/site-packages/cryptography/hazmat/bindings/_rust.abi3.so", + ], capture_output=True, - ] + ) assert False, (p.stdout.decode(), p.stderr.decode()) From 5061e57d8c27593d90496fc0ff5aa2ed5a942dbb Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sun, 13 Jul 2025 23:03:14 -0700 Subject: [PATCH 4/7] handle_macho expects string arguments --- relenv/runtime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relenv/runtime.py b/relenv/runtime.py index e2e1e9b4..1d71e359 100644 --- a/relenv/runtime.py +++ b/relenv/runtime.py @@ -337,7 +337,7 @@ def wrapper( debug(f"Relenv - Found elf {file}") relocate().handle_elf(plat / file, rootdir / "lib", True, rootdir) elif relocate().is_macho(file): - relocate().handle_macho(plat / file, rootdir, True) + relocate().handle_macho(str(plat / file), str(rootdir), True) return wrapper From 95e909e25e6f45a498ea113d5d5fa28aee6add22 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sun, 13 Jul 2025 23:17:51 -0700 Subject: [PATCH 5/7] Fix rpath test --- tests/test_verify_build.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_verify_build.py b/tests/test_verify_build.py index 816da62a..31c8b342 100644 --- a/tests/test_verify_build.py +++ b/tests/test_verify_build.py @@ -866,8 +866,7 @@ def test_cryptography_rpath_darwin(pipexec, build, minor_version, cryptography_v ], capture_output=True, ) - - assert False, (p.stdout.decode(), p.stderr.decode()) + assert "/usr/local" not in p.stdout.decode(), p.stdout.decode() @pytest.mark.skip_unless_on_linux From b0cfacaf8b3f979114fbe571ca92a4442b8fd8f9 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sun, 13 Jul 2025 23:37:56 -0700 Subject: [PATCH 6/7] Add forward capatability flag for 3.13 --- tests/test_verify_build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_verify_build.py b/tests/test_verify_build.py index 31c8b342..93d96db6 100644 --- a/tests/test_verify_build.py +++ b/tests/test_verify_build.py @@ -847,6 +847,10 @@ def test_cryptography_rpath_darwin(pipexec, build, minor_version, cryptography_v env = os.environ.copy() env["RELENV_BUILDENV"] = "yes" env["OPENSSL_DIR"] = f"{build}" + + if minor_version == "3.13": + env["PYO3_USE_ABI3_FORWARD_COMPATIBILITY"] = "1" + p = subprocess.run( [ str(pipexec), @@ -1457,9 +1461,12 @@ def test_install_with_target_namespaces(pipexec, build, minor_version, build_ver @pytest.mark.skip_unless_on_linux -def test_debugpy(pipexec, build, minor_version): +def test_debugpy(pipexec, build, arch, minor_version): if "3.13" in minor_version: pytest.xfail("Failes on python 3.13.0") + if arch == "arm64": + pytest.xfail("Failes on arm64") + p = subprocess.run( [ str(pipexec), From edddf4a375d73fdbf4b4d8f5ce1223e42a3cf6fa Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 14 Jul 2025 14:05:31 -0700 Subject: [PATCH 7/7] Work around missing otool --- relenv/runtime.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/relenv/runtime.py b/relenv/runtime.py index 1d71e359..0740be8f 100644 --- a/relenv/runtime.py +++ b/relenv/runtime.py @@ -337,7 +337,13 @@ def wrapper( debug(f"Relenv - Found elf {file}") relocate().handle_elf(plat / file, rootdir / "lib", True, rootdir) elif relocate().is_macho(file): - relocate().handle_macho(str(plat / file), str(rootdir), True) + otool_bin = shutil.which("otool") + if otool_bin: + relocate().handle_macho(str(plat / file), str(rootdir), True) + else: + debug( + "The otool command is not available, please run `xcode-select --install`" + ) return wrapper