Skip to content

Commit

Permalink
Calculate the CFLAGS match early and simply include that in the choic…
Browse files Browse the repository at this point in the history
…e on whether to change the root.
  • Loading branch information
jaraco committed Jul 31, 2022
1 parent 25dcca2 commit bd7613f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions distutils/unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,20 +345,16 @@ def _library_root(dir):
vs
/usr/lib/libedit.dylib
"""
if sys.platform != 'darwin' or not (
cflags = sysconfig.get_config_var('CFLAGS')
match = re.search(r'-isysroot\s*(\S+)', cflags)

if sys.platform != 'darwin' or not match or not (
dir.startswith('/System/')
or (dir.startswith('/usr/') and not dir.startswith('/usr/local/'))
):
return dir

cflags = sysconfig.get_config_var('CFLAGS')
m = re.search(r'-isysroot\s*(\S+)', cflags)
if m is None:
sysroot = '/'
else:
sysroot = m.group(1)

return os.path.join(sysroot, dir[1:])
return os.path.join(match.group(1), dir[1:])

def find_library_file(self, dirs, lib, debug=0):
"""
Expand Down

0 comments on commit bd7613f

Please sign in to comment.