-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
setup.py
157 lines (136 loc) · 5.02 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
import importlib.util as iutil
import platform
from os.path import join
import numpy as np
from Cython.Distutils import build_ext
from Cython.Build import cythonize
from setuptools import Extension
from setuptools import setup, find_packages
from setuptools.discovery import FlatLayoutPackageFinder
# When updating the version, one must also update the docs/source/_static/switcher.json file
version = 1.1
minor_version = 2
release_version = f"{version}.{minor_version}"
include_dirs = [np.get_include()]
libraries = []
library_dirs = []
if iutil.find_spec("pyarrow") is not None:
import pyarrow as pa
pa.create_library_symlinks()
include_dirs.append(pa.get_include())
libraries.extend(pa.get_libraries())
library_dirs.extend(pa.get_library_dirs())
is_win = "WINDOWS" in platform.platform().upper()
is_mac = any(e in platform.platform().upper() for e in ["MACOS", "DARWIN"])
prefix = "/" if is_win else "-f"
cpp_std = "/std:c++17" if is_win else "-std=c++17"
compile_args = [cpp_std, f"{prefix}openmp{':llvm' if is_win else ''}"]
compile_args += ["-Wno-unreachable-code"] if is_mac else []
link_args = [f"{prefix}openmp"]
extension_args = {
"extra_compile_args": compile_args,
"extra_link_args": link_args,
"define_macros": [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
"include_dirs": include_dirs,
"libraries": libraries,
"library_dirs": library_dirs,
"language": "c++",
}
ext_mod_aon = Extension("aequilibrae.paths.AoN", [join("aequilibrae", "paths", "cython", "AoN.pyx")], **extension_args)
ext_mod_ipf = Extension(
"aequilibrae.distribution.ipf_core",
[join("aequilibrae", "distribution", "cython", "ipf_core.pyx")],
**extension_args,
)
ext_mod_put = Extension(
"aequilibrae.paths.public_transport",
[join("aequilibrae", "paths", "cython", "public_transport.pyx")],
**extension_args,
)
ext_mod_rc = Extension(
"aequilibrae.paths.cython.route_choice_set",
[join("aequilibrae", "paths", "cython", "route_choice_set.pyx")],
**extension_args,
)
ext_mod_rc_ll_results = Extension(
"aequilibrae.paths.cython.route_choice_link_loading_results",
[join("aequilibrae", "paths", "cython", "route_choice_link_loading_results.pyx")],
**extension_args,
)
ext_mod_rc_set_results = Extension(
"aequilibrae.paths.cython.route_choice_set_results",
[join("aequilibrae", "paths", "cython", "route_choice_set_results.pyx")],
**extension_args,
)
ext_mod_graph_building = Extension(
"aequilibrae.paths.graph_building",
[join("aequilibrae", "paths", "cython", "graph_building.pyx")],
**extension_args,
)
ext_mod_sparse_matrix = Extension(
"aequilibrae.matrix.sparse_matrix",
[join("aequilibrae", "matrix", "sparse_matrix.pyx")],
**extension_args,
)
ext_mod_coo_demand = Extension(
"aequilibrae.matrix.coo_demand",
[join("aequilibrae", "matrix", "coo_demand.pyx")],
**extension_args,
)
with open("requirements.txt", "r") as fl:
install_requirements = [x.strip() for x in fl.readlines()]
pkgs = find_packages(exclude=FlatLayoutPackageFinder.DEFAULT_EXCLUDE)
pkg_data = {
"aequilibrae.reference_files": ["spatialite.sqlite", "nauru.zip", "sioux_falls.zip", "coquimbo.zip"],
"aequilibrae.paths": ["cython/*.pxi", "cython/*.pyx", "cython/*.pxd"],
"aequilibrae.distribution": ["cython/*.pyx"],
"aequilibrae.matrix": ["*.pyx", "*.pxd"],
"aequilibrae": ["./parameters.yml", "../requirements.txt"],
"aequilibrae.project": [
"database_specification/network/tables/*.*",
"database_specification/network/triggers/*.*",
"database_specification/transit/tables/*.*",
"database_specification/transit/triggers/*.*",
],
}
with open("README.md", "r") as fh:
long_description = fh.read()
if __name__ == "__main__":
setup(
name="aequilibrae",
version=release_version, # noqa: F821
install_requires=install_requirements,
packages=pkgs,
package_dir={"": "."},
package_data=pkg_data,
zip_safe=False,
description="A package for transportation modeling",
long_description=long_description,
author="Pedro Camargo",
author_email="[email protected]",
url="https://github.com/AequilibraE/aequilibrae",
license="See LICENSE.TXT",
license_files=("LICENSE.TXT",),
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
cmdclass={"build_ext": build_ext},
ext_modules=cythonize(
[
ext_mod_aon,
ext_mod_ipf,
ext_mod_put,
ext_mod_rc,
ext_mod_coo_demand,
ext_mod_rc_ll_results,
ext_mod_rc_set_results,
ext_mod_graph_building,
ext_mod_sparse_matrix,
],
compiler_directives={"language_level": "3str"},
),
)