From 20fd6631b8678d5e64ded9c8c7e2d1ca0c345785 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:35:22 -0400 Subject: [PATCH] ENH: Don't add system library directories to rpath Last of the patches from #73 Might close pypa/setuptools#3257 Dual purposes here: - On platforms like Cygwin that don't have `rpath`, try to avoid adding things to `rpath` - Some distribution binary package makers require that no shared library list a system library directory (`/lib`, `/lib64`, `/usr/lib`, `/usr/lib64`) in its `rpath`; this patch simplifies the code to ensure the shared library can find its dependencies at runtime. --- distutils/unixccompiler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/distutils/unixccompiler.py b/distutils/unixccompiler.py index 4be74fdf..7de39e96 100644 --- a/distutils/unixccompiler.py +++ b/distutils/unixccompiler.py @@ -139,6 +139,15 @@ class UnixCCompiler(CCompiler): if sys.platform == "cygwin": exe_extension = ".exe" + def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs): + """Remove standard library path from rpath""" + libraries, library_dirs, runtime_library_dirs = super()._fix_lib_args( + libraries, library_dirs, runtime_library_dirs) + libdir = sysconfig.get_config_var('LIBDIR') + if runtime_library_dirs and (libdir in runtime_library_dirs): + runtime_library_dirs.remove(libdir) + return libraries, library_dirs, runtime_library_dirs + def preprocess( self, source,