Skip to content

Commit

Permalink
setup
Browse files Browse the repository at this point in the history
  • Loading branch information
wannesm committed Oct 6, 2022
1 parent fc9988f commit 982a8c3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
license_file = LICENSE
license_files = LICENSE
description = Distance measures for time series (Dynamic Time Warping, fast C implementation)
name = dtaidistance
version = attr: dtaidistance.__version__
Expand Down
73 changes: 36 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,6 @@
}


# See which paths for libraries exist to add to compiler
# MacPorts
p = Path('/usr/local/opt/libomp/include')
if p.exists():
print(f'Adding path to compiler {p}')
c_args['unix'].append(f'-I{p}')
c_args['llvm'].append(f'-I{p}')
p = Path('/opt/local/lib/libomp')
if p.exists():
print(f'Adding path to linker {p}')
l_args['unix'].append(f'-L{p}')
l_args['llvm'].append(f'-L{p}')
# HomeBrew
p = Path('/opt/homebrew/include')
if p.exists():
print(f'Adding path to compiler: {p}')
c_args['unix'].append(f'-I{p}')
c_args['llvm'].append(f'-I{p}')
p = Path('/opt/homebrew/lib')
if p.exists():
print(f'Adding path to linker: {p}')
l_args['unix'].append(f'-L{p}')
l_args['llvm'].append(f'-L{p}')


class PyTest(TestCommand):
description = "Run tests"
user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
Expand Down Expand Up @@ -246,18 +221,6 @@ def print2(*args, **kwargs):
else:
gcc_is_clang = False

if self.distribution.forcestatic:
libomp = Path(p / 'libomp.a')
if platform.system() == 'Darwin' and libomp.exists():
# Force the linker to use the static libomp.a library
# This is useful to create wheels for people who do not
# have the shared library libomp.{dylib,so} in the right location
print(f'Removing -lomp and adding libomp to linker: {libomp}')
l_args['unix'] = [a for a in l_args['unix'] if a != '-lomp']
l_args['llvm'] = [a for a in l_args['llvm'] if a != '-lomp']
l_args['unix'].append(str(libomp))
l_args['llvm'].append(str(libomp))

if self.distribution.forcellvm or gcc_is_clang or \
(c == "unix" and ("llvm" in self.compiler.compiler[0] or
"clang" in self.compiler.compiler[0])):
Expand All @@ -277,6 +240,42 @@ def print2(*args, **kwargs):
c = 'gnugcc'

if self.distribution.noopenmp == 0 and self.distribution.forceopenmp == 0:
# See which paths for libraries exist to add to compiler
# MacPorts
p = Path('/usr/local/opt/libomp/include')
if p.exists():
print(f'Adding path to compiler {p}')
c_args['unix'].append(f'-I{p}')
c_args['llvm'].append(f'-I{p}')
p = Path('/opt/local/lib/libomp')
if p.exists():
print(f'Adding path to linker {p}')
l_args['unix'].append(f'-L{p}')
l_args['llvm'].append(f'-L{p}')
# HomeBrew
p = Path('/opt/homebrew/include')
if p.exists():
print(f'Adding path to compiler: {p}')
c_args['unix'].append(f'-I{p}')
c_args['llvm'].append(f'-I{p}')
p = Path('/opt/homebrew/lib')
if p.exists():
libomp = Path(p / 'libomp.a')
if self.distribution.forcestatic and platform.system() == 'Darwin' and libomp.exists():
# Force the linker to use the static libomp.a library
# This is useful to create wheels for people who do not
# have the shared library libomp.{dylib,so} in the right location
print(f'Removing -lomp and adding libomp to linker: {libomp}')
l_args['unix'] = [a for a in l_args['unix'] if a != '-lomp']
l_args['llvm'] = [a for a in l_args['llvm'] if a != '-lomp']
l_args['unix'].append(str(libomp))
l_args['llvm'].append(str(libomp))
else:
print(f'Adding path to linker: {p}')
l_args['unix'].append(f'-L{p}')
l_args['llvm'].append(f'-L{p}')

# Try to check availability of OpenMP
try:
check_result = check_openmp(self.compiler.compiler[0], self.distribution.noxpreprocessor,
printfn=print2)
Expand Down

0 comments on commit 982a8c3

Please sign in to comment.