From 9d45f137d8a462d86f996c9ac8ad59390b4c8001 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 21 Sep 2022 12:21:31 -0400 Subject: [PATCH] TST: Use different library file for link test The old test seemed to pick up the 32-bit library, not the 64-bit one. The new test should pick up the 64-bit one consistently when relevant. --- distutils/tests/test_build_ext.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/distutils/tests/test_build_ext.py b/distutils/tests/test_build_ext.py index ba494fef..a88554db 100644 --- a/distutils/tests/test_build_ext.py +++ b/distutils/tests/test_build_ext.py @@ -6,6 +6,7 @@ import re import shutil import site +import subprocess import sys import tempfile import textwrap @@ -112,8 +113,8 @@ def test_build_ext(self, copy_so): ) elif sys.platform == 'linux': libz_so = glob.glob('/usr/lib*/libz.so*') - shutil.copyfile(libz_so[0], '/tmp/libxx_z.so') - + shutil.copyfile(libz_so[-1], '/tmp/libxx_z.so') + xx_ext = Extension( 'xx', [xx_c], @@ -140,7 +141,7 @@ def test_build_ext(self, copy_so): with safe_extension_import('xx', self.tmp_dir): self._test_xx(copy_so) - + if sys.platform == 'linux' and copy_so: os.unlink('/tmp/libxx_z.so') @@ -159,9 +160,11 @@ def _test_xx(copy_so): assert xx.__doc__ == doc assert isinstance(xx.Null(), xx.Null) assert isinstance(xx.Str(), xx.Str) - + if sys.platform == 'linux': - so_headers = subprocess.check_output(["readelf", "-d", xx.__file__], universal_newlines=True) + so_headers = subprocess.check_output( + ["readelf", "-d", xx.__file__], universal_newlines=True + ) if not copy_so: # Linked against a library in /usr/lib{,64} assert 'RPATH' not in so_headers and 'RUNPATH' not in so_headers