-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.py
64 lines (52 loc) · 1.88 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
import os
from pybind11.setup_helpers import STD_TMPL, WIN, Pybind11Extension
from setuptools import find_packages, setup
version = open("VERSION").read()
description = open("README.md").read()
dir_path = os.path.dirname(os.path.realpath(__file__))
for float_type in ["float", "double"]:
tmpl_args = dict(float_type=float_type)
import mako.lookup
tmpl_fp = "cutde/cpp_backend.cpp"
tmpl_name = os.path.basename(tmpl_fp)
lookup = mako.lookup.TemplateLookup(directories=["cutde"])
tmpl = lookup.get_template(tmpl_name)
try:
rendered_tmpl = tmpl.render(**tmpl_args, backend="cpp", preamble="")
except: # noqa: E722
# bare except is okay because we re-raise immediately
import mako.exceptions
print(mako.exceptions.text_error_template().render())
raise
rendered_fp = os.path.join(
os.path.dirname(tmpl_fp), f".rendered.{float_type}.{tmpl_name}"
)
with open(rendered_fp, "w") as f:
f.write(rendered_tmpl)
OPENMP_FLAG = "/openmp" if WIN else "-fopenmp"
ext_modules = [
Pybind11Extension(
f"cutde.cpp_backend_{float_type}",
[f"cutde/.rendered.{float_type}.cpp_backend.cpp"],
extra_compile_args=[OPENMP_FLAG, STD_TMPL.format("17")],
extra_link_args=[] if WIN else [OPENMP_FLAG],
)
for float_type in ["float", "double"]
]
setup(
packages=find_packages(),
install_requires=["mako", "pybind11"],
ext_modules=ext_modules,
zip_safe=False,
include_package_data=True,
name="cutde",
version=version,
description="130 million TDEs per second, Python + CUDA TDEs from Nikkhoo and Walter 2015", # noqa:E501
long_description=description,
long_description_content_type="text/markdown",
url="https://github.com/tbenthompson/cutde",
author="T. Ben Thompson",
author_email="[email protected]",
license="MIT",
platforms=["any"],
)