-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
147 lines (132 loc) · 5.41 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
#!/usr/bin/env python3
from setuptools import setup, Extension, Command
import os.path
import os
import platform
import setuptools
import sys
import glob
print("Building on:", sys.version)
with open("requirements.txt", "r", encoding="utf8") as fh:
requirements = fh.readlines()
enableParallelism = True
extraOptions = []
extraLibraryPaths = []
extraIncludesPaths = []
extraLinkOptions=[]
compilerOptions = [
# "-g",
"-std=c11",
# "-m64",
"-Wall",
"-Wno-unused-function",
"-Wno-deprecated-declarations",
"-Wno-sign-compare",
"-Wno-strict-prototypes",
"-Wno-unused-variable",
"-O3",
# "-fvisibility=hidden",
"-funroll-loops",
"-fstrict-aliasing"
]
if(platform.system()=="Darwin"):
extraOptions = ["-D OSX"]
if(enableParallelism):
extraOptions += ["-DCV_USE_LIBDISPATCH=1"]
elif(platform.system()=="Windows"):
# extraOptions += ["-D WIN32 -lpthread"]
extraOptions += ["/D WIN32"]
extraOptions += ["/D __WIN32__"]
compilerOptions = [
"/std:c11",
"/Wall",
"/O2",
# "-funroll-loops",
# "-fstrict-aliasing"
]
if(enableParallelism):
# extraOptions += ["-DCV_USE_OPENMP=1","-fopenmp"]
# extraLinkOptions += ["-lgomp"]
# extraLinkOptions+=["-lgomp"]
extraOptions+=["/D CV_USE_OPENMP=1"]
extraOptions+=["/openmp"]
if("VCPKG_INSTALLATION_ROOT" in os.environ):
extraIncludesPaths += [os.path.join(os.environ["VCPKG_INSTALLATION_ROOT"], "installed", "x64-windows-static","include")]
extraLibraryPaths += [os.path.join(os.environ["VCPKG_INSTALLATION_ROOT"], "installed", "x64-windows-static","lib")]
elif(platform.system()=="Linux"):
extraOptions = ["-D Linux","-D_GNU_SOURCE=1"]
if(enableParallelism):
extraOptions += ["-DCV_USE_OPENMP=1","-fopenmp"]
extraLinkOptions+=["-lgomp"]
else:
if(enableParallelism):
extraOptions += ["-DCV_USE_OPENMP=1","-fopenmp"]
extraLinkOptions+=["-lgomp"]
# WORKAROUND: https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
class get_numpy_include(object):
def __str__(self):
import numpy
return numpy.get_include()
with open("README.md", "r") as fh:
long_description = fh.read()
building_on_windows = platform.system() == "Windows"
print("!!!!!Building on",platform.system(),"!!!!!!")
packageName = "network-symmetry"
packageDirectory = "network_symmetry"
extensionPackageName = "network_symmetry_core"
with open(os.path.join(packageDirectory, "Python", "PyCXVersion.h"), "rt") as fd:
version = fd.readline().strip().split(" ")[-1]
print("Compiling version %s"%version)
setup(
name=packageName,
version=version,
author="Filipi N. Silva, Alexandre Benatti, Henrique F. Arruda",
author_email="filsilva@iu.edu, alexandre.benatti@usp.br, h.f.arruda@gmail.com",
# compiler = "mingw32" if building_on_windows else None,
install_requires=[req for req in requirements if req[:2] != "# "],
setup_requires=["wheel","numpy","scipy"],
description="Library to compute accessibility and symmetry in networks",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ABenatti/network-accessibility",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Development Status :: 3 - Alpha",
"Programming Language :: C",
"Topic :: Scientific/Engineering :: Information Analysis",
"Intended Audience :: Science/Research"
],
python_requires='>=3.6',
ext_modules = [
Extension(
extensionPackageName,
sources=[
os.path.join(packageDirectory,"Source", "CVSimpleQueue.c"),
os.path.join(packageDirectory,"Source", "CVSet.c"),
os.path.join(packageDirectory,"Source", "CVNetwork.c"),
os.path.join(packageDirectory,"Source", "CVDictionary.c"),
os.path.join(packageDirectory,"Source", "CVDistribution.c"),
os.path.join(packageDirectory,"Source", "fib.c"),
os.path.join(packageDirectory,"Source", "CVNetworkSymmetry.c"),
os.path.join(packageDirectory,"Source", "CVConcentricStructure.c"),
os.path.join(packageDirectory,"Source", "CVNetworkCentrality.c"),
os.path.join(packageDirectory,"Python", "PySymmetry.c"),
os.path.join(packageDirectory,"Python", "CVSymmetryApplication.c"),
],
include_dirs=[
os.path.join(packageDirectory,"Source"),
os.path.join(packageDirectory,"Python"),
get_numpy_include()
]+extraIncludesPaths,
extra_compile_args=compilerOptions+extraOptions,
extra_link_args=extraLinkOptions,
library_dirs=extraLibraryPaths,
libraries = ["getopt"] if building_on_windows else [],
),
]
)