-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.py
94 lines (81 loc) · 3.11 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from setuptools import setup, find_packages
from setuptools.extension import Extension
from setuptools.command.sdist import sdist as _sdist
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.build_ext import build_ext as _build_ext
import os
import sys
sys.path.insert(0, 'caesar')
from __version__ import VERSION
class build_py(_build_py):
def run(self):
_build_py.run(self)
class build_ext(_build_ext):
# subclass setuptools extension builder to avoid importing numpy
# at top level in setup.py. See http://stackoverflow.com/a/21621689/1382869
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process
# see http://stackoverflow.com/a/21621493/1382869
from six.moves import builtins
builtins.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
class sdist(_sdist):
# subclass setuptools source distribution builder to ensure cython
# generated C files are included in source distribution.
# See http://stackoverflow.com/a/18418524/1382869
def run(self):
# Make sure the compiled Cython files in the distribution are up-to-date
from Cython.Build import cythonize
cythonize(cython_extensions,
compiler_directives={'language_level' : "3"}
)
_sdist.run(self)
if sys.platform == 'darwin':
compile_arg = ""
link_arg = ""
else:
compile_arg = "-fopenmp"
link_arg = '-fopenmp'
cython_extensions = [
Extension('caesar.group_funcs',
sources=['caesar/group_funcs/group_funcs.pyx'],
extra_compile_args=[compile_arg],
extra_link_args=[link_arg]),
Extension('caesar.hydrogen_mass_calc',
sources=['caesar/hydrogen_mass_calc/hydrogen_mass_calc.pyx'],
extra_compile_args=[compile_arg],
extra_link_args=[link_arg]),
Extension('caesar.cyloser',
sources=['caesar/pyloser/cyloser.pyx'],
extra_compile_args=[compile_arg],
extra_link_args=[link_arg])
]
for e in cython_extensions:
e.cython_directives = {'language_level': "3"} #all are Python-3
setup(
name='caesar',
version=VERSION,
description='CAESAR is a python library for analyzing the outputs from cosmological simulations.',
url='https://github.com/dnarayanan/caesar',
author='Robert Thompson, Desika Narayanan, Romeel Dave, Benjamin Kimock',
author_email='[email protected]',
license='not sure',
classifiers=[],
keywords='',
entry_points={'console_scripts': ['caesar = caesar.command_line:run']},
packages=find_packages(),
setup_requires=['six', 'numpy', 'cython>=3.0'],
install_requires=[
'six', 'numpy', 'h5py', 'cython', 'psutil', 'scipy', 'joblib', 'scikit-learn',
'yt', 'astropy'#,
#'pygadgetreader @ git+https://github.com/dnarayanan/pygadgetreader'
],
cmdclass={
'sdist': sdist,
'build_ext': build_ext,
'build_py': build_py
},
ext_modules=cython_extensions,
)