-
Notifications
You must be signed in to change notification settings - Fork 83
/
setup.py
131 lines (105 loc) · 4.05 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
import os
import sys
import numpy as np # for c++ headers
from setuptools import find_packages, setup, Extension
###############################################
# Building the C++ extension
###############################################
extra_compile_args = ["-w", "-std=c++11", "-O3"]
extra_link_args = []
# Mac compilation: flags are for the llvm compilers included with recent
# versions of Xcode Command Line Tools, or newer versions installed separately
if sys.platform.startswith("darwin"): # Mac
extra_compile_args += ["-stdlib=libc++"]
extra_link_args += ["-stdlib=libc++"]
# The default compiler that ships with Macs doesn't support OpenMP multi-
# threading. We recommend using the Conda toolchain instead, but will also
# try to detect if people are using another alternative like Homebrew.
if "CC" in os.environ:
extra_compile_args += ["-fopenmp"]
print(
"Attempting Pandana compilation with OpenMP multi-threading "
"support, with user-specified compiler:\n{}".format(os.environ["CC"])
)
# Otherwise, if the default clang has been replaced but nothing specified
# in the 'CC' environment variable, assume they've followed our instructions
# for using the Conda toolchain.
elif os.popen("which clang").read().strip() != "/usr/bin/clang":
cc = "clang"
cc_catalina = (
"clang --sysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
)
extra_compile_args += ["-fopenmp"]
print(
"Attempting Pandana compilation with OpenMP multi-threading "
"support, with the following compiler:\n{}".format(
os.popen("which clang").read()
)
)
if " 10.15" in os.popen("sw_vers").read():
os.environ["CC"] = cc_catalina
elif " 10." in os.popen("sw_vers").read(): # 10.14 and earlier
os.environ["CC"] = cc
else: # 11.x, 12.x, etc.
os.environ["CC"] = cc_catalina
else:
print(
"Attempting Pandana compilation without support for "
"multi-threading. See installation instructions for alternative "
"options"
)
# Window compilation: flags are for Visual C++
elif sys.platform.startswith("win"): # Windows
extra_compile_args = ["/w", "/openmp"]
# Linux compilation: flags are for gcc 4.8 and later
else: # Linux
extra_compile_args += ["-fopenmp"]
extra_link_args += ["-lgomp"]
cyaccess = Extension(
name='pandana.cyaccess',
sources=[
'src/accessibility.cpp',
'src/graphalg.cpp',
'src/cyaccess.pyx',
'src/contraction_hierarchies/src/libch.cpp'],
language='c++',
include_dirs=['.', np.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)
###############################################
# Standard setup
###############################################
version = "0.7"
packages = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])
setup(
packages=packages,
name="pandana",
author="UrbanSim Inc.",
version=version,
license="AGPL",
description=("Python library for network analysis"),
long_description=(
"Pandana is a Python library for network analysis that uses "
"contraction hierarchies to calculate super-fast travel "
"accessibility metrics and shortest paths. The numerical "
"code is in C++."
),
url="https://udst.github.io/pandana/",
ext_modules=[cyaccess],
install_requires=[
'numpy >=1.8',
'pandas >=0.17',
'requests >=2.0',
'scikit-learn >=0.18',
'tables >=3.1'
],
classifiers=[
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: GNU Affero General Public License v3",
],
)