-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
106 lines (91 loc) · 2.78 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
#!/usr/bin/env python
###################################################################
# SiPM - Silicon Photomultipliers simulation toolkit. Developed for high energy physics and particle phisics simulations.
#
# License: MIT
# Author: Edoardo Proserpio
#
####################################################################
from setuptools import setup
from glob import glob
from pybind11.setup_helpers import (
Pybind11Extension,
build_ext,
ParallelCompile,
naive_recompile,
)
import os
import platform
with open("README.md", encoding="utf-8") as f:
LONG_DESCRIPTION = f.read()
if os.environ.get("NPY_NUM_BUILD_JOBS"):
ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install()
else:
ParallelCompile(needs_recompile=naive_recompile).install()
# Default version
__version__ = "0.0.0"
for l in open("include/SiPM.h").readlines():
if "SIPM_VERSION" in l.split():
__version__ = l.split()[-1].strip('"')
break
extra_compile_args = [
"-DNDEBUG",
"-O3",
"-ffast-math",
"-funsafe-math-optimizations",
"-mfma",
"-mavx2",
]
if platform.system() == "Darwin":
# On MacOS
extra_compile_args.append("-fno-aligned-allocation")
sources = []
sources.extend(glob("src/*.cpp"))
sources.extend(glob("python/*.cpp"))
include_dirs = ["include/"]
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked."""
def __init__(self, user=False):
self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
ext_modules = [
Pybind11Extension(
"SiPM",
sources=sorted(sources),
include_dirs=[
include_dirs,
get_pybind_include(),
get_pybind_include(user=True),
],
extra_compile_args=extra_compile_args,
language="c++",
),
]
setup(
name="SiPM",
version=__version__,
author="Edoardo Proserpio",
author_email="edoardo.proserpio@gmail.com",
maintainer="Edoardo Proserpio",
maintainer_email="edoardo.proserpio@gmail.com",
url="https://github.com/EdoPro98/SimSiPM",
description="Library for Silicon Photomultipliers simulation.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
ext_modules=ext_modules,
include_dirs=include_dirs,
cmdclass={"build_ext": build_ext},
zip_safe=False,
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: Physics",
"Programming Language :: Python :: 3",
],
)