-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
108 lines (100 loc) · 3.38 KB
/
setup.py
File metadata and controls
108 lines (100 loc) · 3.38 KB
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
# Copyright (c) 2023-2024 The Regents of the University of Michigan.
# This file is from the StructuralGT project, released under the BSD 3-Clause
# License.
import json
import os
import platform
import numpy
from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup
metadata = {}
if os.environ.get("C_FLAG") is None or os.environ.get("C_FLAG") == "TRUE":
metadata["C_FLAG"] = True
elif os.environ.get("C_FLAG") == "FALSE":
metadata["C_FLAG"] = False
else:
raise ValueError("Environment variable, C_FLAG, has an invalid value.")
with open("StructuralGT/metadata.json", "w") as json_file:
json.dump(metadata, json_file)
if os.getenv("CONDA_PREFIX") is not None:
PRE_PREFIX = os.getenv("CONDA_PREFIX")
elif os.getenv("CONDA_ENVS_PATH") is not None:
PRE_PREFIX = os.path.join(os.getenv("CONDA_ENVS_PATH"), "latest")
else:
raise ValueError("Could not identify env prefix")
if platform.system() == "Windows":
PREFIX = os.path.join(PRE_PREFIX, "Library")
extra_obj = os.path.join(PREFIX, "lib", "igraph.lib")
freud = "freud-analysis"
else:
PREFIX = PRE_PREFIX
extra_obj = "-ligraph"
freud = "freud"
if metadata["C_FLAG"]:
assert PREFIX is not None
include_dirs = [
os.path.join(PREFIX, "include", "igraph"),
os.path.join(PREFIX, "include", "eigen3"),
]
setup(
name="StructuralGT",
packages=find_packages(),
setup_requires=["cython"],
ext_modules=cythonize(
[
Extension(
name="StructuralGT._boundary_betweenness_cast",
sources=["StructuralGT/_boundary_betweenness_cast.pyx"],
include_dirs=include_dirs,
language="c++",
extra_objects=[extra_obj],
),
Extension(
name="StructuralGT._vertex_boundary_betweenness_cast",
sources=[
"StructuralGT/_vertex_boundary_betweenness_cast.pyx"
],
include_dirs=include_dirs,
language="c++",
extra_objects=[extra_obj],
),
Extension(
name="StructuralGT._random_boundary_betweenness_cast",
sources=[
"StructuralGT/_random_boundary_betweenness_cast.pyx"
],
include_dirs=include_dirs,
language="c++",
extra_objects=[extra_obj],
),
Extension(
name="StructuralGT._average_nodal_connectivity_cast",
sources=[
"StructuralGT/_average_nodal_connectivity_cast.pyx"
],
include_dirs=include_dirs,
language="c++",
extra_objects=[extra_obj],
),
]
),
zip_safe=False,
package_data={
"StructuralGT": [
"pytest/data/*/*",
"metadata.json",
]
},
)
elif not metadata["C_FLAG"]:
setup(
name="StructuralGT",
packages=find_packages(),
zip_safe=False,
package_data={
"StructuralGT": [
"pytest/data/*/*",
"metadata.json",
]
},
)