-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
179 lines (154 loc) · 4.27 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import os
import os.path as path
import sys
import numpy as np
from setuptools import Extension, find_packages, setup
from setuptools.dist import Distribution
from setuptools.command.test import test as TestCommand
# See recomendations in https://docs.pytest.org/en/latest/goodpractices.html
# noinspection PyAttributeOutsideInit
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ""
def run_tests(self):
import shlex
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)
def load_version():
fd = {}
with open('./mckit/version.py') as fid:
exec(fid.read(), fd)
return (
fd["__title__"],
fd["__author__"],
fd["__license__"],
fd["__copyright__"],
fd["__ver_major__"],
fd["__ver_minor__"],
fd["__ver_patch__"],
fd["__version_info__"],
fd["__ver_sub__"],
fd["__version__"],
)
(
__title__,
__author__,
__license__,
__copyright__,
__ver_major__,
__ver_minor__,
__ver_patch__,
__version_info__,
__ver_sub__,
__version__,
) = load_version()
class BinaryDistribution(Distribution):
def is_pure(self):
return False
def get_dirs(environment_variable):
include_dirs = os.environ.get(environment_variable, "")
if include_dirs:
include_dirs = include_dirs.split(os.pathsep)
else:
include_dirs = []
return include_dirs
def append_if_not_present(destination, value):
if isinstance(value, list):
destination.extend(value)
elif value not in destination:
destination.append(value)
include_dirs = get_dirs("INCLUDE_PATH")
append_if_not_present(include_dirs, np.get_include())
library_dirs = get_dirs("LIBRARY_PATH")
if sys.platform.startswith('linux'):
geometry_dependencies = [
'mkl_intel_lp64',
'mkl_core',
'mkl_sequential',
'nlopt',
]
conda_include_dir = path.join(sys.prefix, "include")
append_if_not_present(include_dirs, conda_include_dir)
append_if_not_present(library_dirs, path.join(sys.prefix, "lib"))
else:
geometry_dependencies = [
'mkl_intel_lp64_dll',
'mkl_core_dll',
'mkl_sequential_dll',
'libnlopt-0',
]
nlopt_inc = get_dirs("NLOPT")
append_if_not_present(include_dirs, nlopt_inc)
nlopt_lib = get_dirs("NLOPT")
append_if_not_present(library_dirs, nlopt_lib)
mkl_inc = sys.prefix + '\\Library\\include'
append_if_not_present(include_dirs, mkl_inc)
mkl_lib = sys.prefix + '\\Library\\lib'
append_if_not_present(library_dirs, mkl_lib)
geometry_sources = [path.join("mckit", "src", src) for src in [
"geometrymodule.c",
"box.c",
"surface.c",
"shape.c",
"rbtree.c",
]]
extensions = [
Extension(
"mckit.geometry",
geometry_sources,
include_dirs=include_dirs,
libraries=geometry_dependencies,
library_dirs=library_dirs,
)
]
packages = find_packages(
include=("mckit", "mckit.*",),
exclude=(
"adhoc",
"build*",
"data",
"dist",
"doc",
"examples",
"htmlcov",
"notebook",
"tutorial",
"tests",
"src",
),
)
setup(
name=__title__,
version=__version__,
packages=packages,
package_data={'mckit': ['data/isotopes.dat', 'libnlopt-0.dll']},
url='https://gitlab.iterrf.ru/Rodionov/mckit',
license=__license__,
author=__author__,
author_email='[email protected]',
description='Tool for handling neutronic models and results',
install_requires=[
'attrs>=17.2.0',
'click>=6.7',
'click-log>=0.3.2',
'mkl-devel',
'numpy',
'ply',
'scipy',
'tomlkit',
'datetime',
'sly',
],
ext_modules=extensions,
tests_require=['pytest', 'pytest-cov>=2.3.1', 'pytest-benchmark'],
cmdclass={'test': PyTest},
entry_points={
'console_scripts': [
'mckit = mckit.cli.runner:mckit',
]
},
)