Workaround distutils bug 36353; see https://bugs.python.org/issue36353. On MacOS, the build_ext--rpath option is getting converted to -L rather than -Wl,-rpath=. This change sub-classes build_ext and correctly passes appropriate rpath options to clang linker.
Snippet from distutils.unixccompiler.py:
compiler = os.path.basename(sysconfig.get_config_var("CC"))
if sys.platform[:6] == "darwin":
# MacOSX's linker doesn't understand the -R flag at all
return "-L" + dir
elif sys.platform[:7] == "freebsd":
return "-Wl,-rpath=" + dir
elif sys.platform[:5] == "hp-ux":
if self._is_gcc(compiler):
return ["-Wl,+s", "-L" + dir]
return ["+s", "-L" + dir]
Workaround
distutils
bug 36353; see https://bugs.python.org/issue36353. On MacOS, thebuild_ext
--rpath
option is getting converted to-L
rather than-Wl,-rpath=
. This change sub-classesbuild_ext
and correctly passes appropriate rpath options to clang linker.Snippet from
distutils.unixccompiler.py
:Workaround code taken from https://github.com/python/cpython/pull/12418.