Skip to content

Commit

Permalink
Merge db3c3d1 into 620281c
Browse files Browse the repository at this point in the history
  • Loading branch information
smmaurer committed Jun 3, 2020
2 parents 620281c + db3c3d1 commit 44d4346
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions setup.py
Expand Up @@ -61,17 +61,46 @@ def run(self):

# This environment variable sets the earliest OS version that the compiled
# code will be compatible with. In certain contexts the default is too old
# to allow using libc++; supporting OS X 10.9 and later seems safe
# to allow using libc++; supporting OS X 10.9 and later seems reasonable
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'

extra_compile_args += ['-D NO_TR1_MEMORY', '-stdlib=libc++']
extra_link_args += ['-stdlib=libc++']

# This checks if the user has replaced the default clang compiler (this does
# not confirm there's OpenMP support, but is the best we could come up with)
if os.popen('which clang').read() != '/usr/bin/clang':
os.environ['CC'] = 'clang'
# The default compiler that ships with Macs doesn't support OpenMP multi-
# threading. We recommend using the Conda toolchain instead, but will also
# try to detect if people are using another alternative like Homebrew.

if 'CC' in os.environ:
extra_compile_args += ['-fopenmp']
print('Attempting Pandana compilation with OpenMP multi-threading '
'support, with user-specified compiler:\n{}'.format(
os.environ['CC']))

# Otherwise, if the default clang has been replaced but nothing specified
# in the 'CC' environment variable, assume they've followed our instructions
# for using the Conda toolchain.

elif os.popen('which clang').read().strip() != '/usr/bin/clang':
cc = 'clang'
cc_catalina = 'clang --sysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

extra_compile_args += ['-fopenmp']
print('Attempting Pandana compilation with OpenMP multi-threading '
'support, with the following compiler:\n{}'.format(
os.popen('which clang').read()))

if '10.15' in os.popen('sw_vers').read():
os.environ['CC'] = cc_catalina
elif '10.16' in os.popen('sw_vers').read():
os.environ['CC'] = cc_catalina
else:
os.environ['CC'] = cc

else:
print('Attempting Pandana compilation without support for '
'multi-threading. See installation instructions for alternative '
'options')

# Window compilation: flags are for Visual C++

Expand Down

0 comments on commit 44d4346

Please sign in to comment.