From 982a8c31dbc9ec52c88d364a31b4ffb3f3c0e4af Mon Sep 17 00:00:00 2001 From: wannesm Date: Thu, 6 Oct 2022 22:06:26 +0200 Subject: [PATCH] setup --- setup.cfg | 2 +- setup.py | 73 +++++++++++++++++++++++++++---------------------------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/setup.cfg b/setup.cfg index 94976520..b3e297b5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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__ diff --git a/setup.py b/setup.py index 57276cf1..de52e266 100755 --- a/setup.py +++ b/setup.py @@ -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")] @@ -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])): @@ -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)