-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsetup.py
125 lines (112 loc) · 3.77 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
import os
import sys
from setuptools import setup, Extension
if __name__ == "__main__":
# The root of the DNest4 repo.
basedir = os.path.dirname(os.path.abspath(__file__))
# Publish the library to PyPI.
if "publish" in sys.argv:
os.system("python setup.py sdist upload")
sys.exit()
if "--without-cext" in sys.argv:
sys.argv.remove("--without-cext")
extensions = []
else:
import glob
from itertools import chain
import numpy
from Cython.Build import cythonize
# Set up the C++-extension.
libraries = []
extra_compile_args = [
"-std=c++11",
"-Wno-unused-function",
"-Wno-uninitialized",
"-DNO_THREADS",
"-DNPY_NO_DEPRECATED_API"
]
extra_link_args = ["-std=c++11"]
if os.name == "posix":
libraries.append("m")
if sys.platform == "darwin":
libraries.append("c++")
extra_compile_args += ["-mmacosx-version-min=10.9"]
extra_link_args += ["-mmacosx-version-min=10.9"]
include_dirs = [
"dnest4",
os.path.join(basedir, "code"),
numpy.get_include(),
]
src = [
os.path.join(basedir, "code", fn)
for fn in chain(
glob.glob(os.path.join(basedir, "code", "*.cpp")),
glob.glob(
os.path.join(basedir, "code", "Distributions", "*.cpp")
),
glob.glob(
os.path.join(
basedir,
"code",
"RJObject",
"ConditionalPriors",
"*.cpp",
)
),
)
]
src += [os.path.join(basedir, "python", "dnest4", "_dnest4.pyx")]
ext = [
Extension(
"dnest4._dnest4",
sources=src,
language="c++",
libraries=libraries,
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"dnest4.utils",
sources=[
os.path.join(basedir, "python", "dnest4", "utils.pyx")
],
language="c++",
libraries=libraries,
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
]
extensions = cythonize(ext)
# Hackishly inject a constant into builtins to enable importing of the
# package before the library is built.
if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins
builtins.__DNEST4_SETUP__ = True
sys.path.insert(0, os.path.join(basedir, "python"))
import dnest4
setup(
name="dnest4",
version=dnest4.__version__,
author="Daniel Foreman-Mackey",
author_email="[email protected]",
url="https://github.com/eggplantbren/DNest4",
license="MIT",
packages=["dnest4"],
package_dir={"": "python"},
ext_modules=extensions,
description="Diffusive nested sampling in Python",
long_description=open("python/README.rst").read(),
classifiers=[
# "Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
],
)