-
Notifications
You must be signed in to change notification settings - Fork 188
/
setup.py
107 lines (94 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
from setuptools import setup, find_packages
from setuptools.extension import Extension
import os
import re
import sys
use_swig = False
build = True
if '--no-build' in sys.argv:
build = False
sys.argv.remove('--no-build')
extension_modules = list()
if build:
import numpy
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
# inplace extension module
project_dir = './' # os.path.dirname(os.path.abspath(__file__))
src_files = os.path.join(project_dir, 'wntr', 'sim', 'aml')
evaluator_cxx = os.path.join(src_files, 'evaluator.cpp')
evaluator_wrap_cxx = os.path.join(src_files, 'evaluator_wrap.cpp')
evaluator_i = os.path.join(src_files, 'evaluator.i')
network_isolation_dir = os.path.join(project_dir, 'wntr', 'sim', 'network_isolation')
network_isolation_cxx = os.path.join(network_isolation_dir, 'network_isolation.cpp')
network_isolation_i = os.path.join(network_isolation_dir, 'network_isolation.i')
network_isolation_wrap_cxx = os.path.join(network_isolation_dir, 'network_isolation_wrap.cpp')
if use_swig:
aml_core_ext = Extension("wntr.sim.aml._evaluator",
sources=[evaluator_i, evaluator_cxx],
language="c++",
extra_compile_args=[],
include_dirs=[numpy_include, src_files],
library_dirs=[],
libraries=[],
swig_opts = ['-c++', '-builtin'])
network_isolation_ext = Extension("wntr.sim.network_isolation._network_isolation",
sources=[network_isolation_i, network_isolation_cxx],
language="c++",
include_dirs=[numpy_include, network_isolation_dir],
extra_compile_args=[],
swig_opts=['-c++', '-builtin'])
else:
aml_core_ext = Extension("wntr.sim.aml._evaluator",
sources=[evaluator_cxx, evaluator_wrap_cxx],
language="c++",
extra_compile_args=[],
include_dirs=[numpy_include, src_files],
library_dirs=[],
libraries=[])
network_isolation_ext = Extension("wntr.sim.network_isolation._network_isolation",
sources=[network_isolation_cxx, network_isolation_wrap_cxx],
language="c++",
include_dirs=[numpy_include, network_isolation_dir],
extra_compile_args=[])
extension_modules.append(aml_core_ext)
extension_modules.append(network_isolation_ext)
DISTNAME = 'wntr'
PACKAGES = find_packages()
EXTENSIONS = extension_modules
DESCRIPTION = 'Water Network Tool for Resilience'
AUTHOR = 'WNTR Developers'
MAINTAINER_EMAIL = '[email protected]'
LICENSE = 'Revised BSD'
URL = 'https://github.com/USEPA/WNTR'
DEPENDENCIES = ['numpy>=1.21,<2.0', 'scipy', 'networkx', 'pandas', 'matplotlib', 'setuptools']
# use README file as the long description
file_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(file_dir, 'README.md'), encoding='utf-8') as f:
LONG_DESCRIPTION = f.read()
# get version from __init__.py
with open(os.path.join(file_dir, 'wntr', '__init__.py')) as f:
version_file = f.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
VERSION = version_match.group(1)
else:
raise RuntimeError("Unable to find version string.")
print(extension_modules)
setup(name=DISTNAME,
version=VERSION,
packages=PACKAGES,
ext_modules=EXTENSIONS,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
author=AUTHOR,
maintainer_email=MAINTAINER_EMAIL,
license=LICENSE,
url=URL,
zip_safe=False,
install_requires=DEPENDENCIES,
scripts=[],
include_package_data=True)