-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
71 lines (59 loc) · 2.26 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import sys
import sysconfig
from setuptools import setup, Extension
import numpy as np
# base directory of package
package_basedir = os.path.abspath(os.path.dirname(__file__))
package_basename = 'pycorr'
sys.path.insert(0, os.path.join(package_basedir, package_basename))
import _version
version = _version.__version__
def find_compiler():
compiler = os.getenv('CC', None)
if compiler is None:
compiler = sysconfig.get_config_vars().get('CC', None)
import platform
uname = platform.uname().system
if compiler is None:
compiler = 'gcc'
if uname == 'Darwin': compiler = 'clang'
return compiler
def compiler_is_clang(compiler):
if compiler == 'clang':
return True
from subprocess import Popen, PIPE
proc = Popen([compiler, '--version'], universal_newlines=True, stdout=PIPE, stderr=PIPE, shell=True)
out, err = proc.communicate()
if 'clang' in out:
return True
return False
def get_flags():
compiler = find_compiler()
os.environ.setdefault('CC', compiler)
if compiler_is_clang(compiler):
flags = ['-Xclang', '-fopenmp', '-lomp']
elif compiler in ['cc', 'icc']:
flags = ['-fopenmp', '-lgomp', '-limf', '-liomp5']
else:
flags = ['-fopenmp', '-lgomp']
flags += ['-DUSE_OMP']
return flags
if __name__ == '__main__':
flags = get_flags()
setup(name=package_basename,
version=version,
author='cosmodesi',
author_email='',
description='Estimation of correlation functions',
license='BSD3',
url='http://github.com/cosmodesi/pycorr',
install_requires=['numpy', 'scipy'],
extras_require={'mpi': ['mpi4py', 'pmesh'], 'jackknife': ['scikit-learn', 'healpy'], 'corrfunc': ['Corrfunc @ git+https://github.com/adematti/Corrfunc@desi']},
ext_modules=[Extension(f'{package_basename}._utils', [f'{package_basename}/_utils.pyx'],
depends=[f'{package_basename}/_utils_imp.h', f'{package_basename}/_utils_generics.h'],
libraries=['m'],
include_dirs=['./', np.get_include()],
extra_compile_args=flags,
extra_link_args=flags)],
packages=[package_basename])