Skip to content

Commit 18203a2

Browse files
committed
ENH: Drop LIBDIR from RPATH only if starting with /usr/lib.
Avoids problems with odd LIBDIR Package managers will be putting things in LIBDIR anyway, so this should catch all use-cases I know of.
1 parent d56a32d commit 18203a2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

distutils/tests/test_build_ext.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import tempfile
1010
import textwrap
11+
import time
1112
from distutils import sysconfig
1213
from distutils.command.build_ext import build_ext
1314
from distutils.core import Distribution
@@ -55,6 +56,9 @@ def user_site_dir(request):
5556
site.USER_BASE = orig_user_base
5657
build_ext.USER_BASE = orig_user_base
5758

59+
if sys.platform == 'cygwin':
60+
time.sleep(1)
61+
5862

5963
@contextlib.contextmanager
6064
def safe_extension_import(name, path):
@@ -95,6 +99,12 @@ def test_build_ext(self):
9599
copy_xxmodule_c(self.tmp_dir)
96100
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
97101
xx_ext = Extension('xx', [xx_c])
102+
if sys.platform != "win32":
103+
xx_ext = Extension(
104+
'xx', [xx_c],
105+
library_dirs=['/usr/lib'], libraries=['z'],
106+
runtime_library_dirs=['/usr/lib']
107+
)
98108
dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
99109
dist.package_dir = self.tmp_dir
100110
cmd = self.build_ext(dist)

distutils/unixccompiler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
153153
libraries, library_dirs, runtime_library_dirs = super()._fix_lib_args(
154154
libraries, library_dirs, runtime_library_dirs)
155155
libdir = sysconfig.get_config_var('LIBDIR')
156-
if runtime_library_dirs and (libdir in runtime_library_dirs):
156+
if (
157+
runtime_library_dirs
158+
and libdir.startswith("/usr/lib")
159+
and (libdir in runtime_library_dirs)
160+
):
157161
runtime_library_dirs.remove(libdir)
158162
return libraries, library_dirs, runtime_library_dirs
159163

0 commit comments

Comments
 (0)