-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·131 lines (105 loc) · 3.52 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·131 lines (105 loc) · 3.52 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python
import os
import sys
from glob import glob
from pathlib import Path
import subprocess
from os.path import basename, splitext
import amoeba
import setuptools
#--------------------------------------------------
version = "0.1.28"
build_type = os.environ.get("OPENSEESRT_BUILD", "release")
#--------------------------------------------------
options = {
"release": [
"-DCMAKE_BUILD_TYPE=RELEASE",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=TRUE",
],
#
"local": [
"-DCMAKE_BUILD_TYPE=RELEASE",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE",
# "-DProfileBuild:BOOL=TRUE",
],
"light": [
"-DCMAKE_BUILD_TYPE=RELEASE",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE",
# "-DProfileBuild:BOOL=TRUE",
],
"debug": [
"-DCMAKE_BUILD_TYPE=DEBUG",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE",
],
"no-build": []
}
use_conan = False
if os.name == "nt":
EnvArgs = [
# "-DCMAKE_TOOLCHAIN_FILE=ifx_toolchain.cmake"
]
use_conan = False
elif "CONDA_PREFIX" in os.environ:
# Ensure that conda libraries and compilers are used
EnvArgs = [
"-DDependencies=Conda",
f"-DCMAKE_PREFIX_PATH:FILEPATH={os.environ['CONDA_PREFIX']}",
f"-DCMAKE_IGNORE_PATH:FILEPATH=/usr/lib/;/lib",
]
else:
EnvArgs = [
"-DDependencies=Unix",
]
OpenSeesPyRT_Config = []
OpenSeesPyRT_Target = []
if use_conan:
# EnvArgs + ["-DCMAKE_TOOLCHAIN_FILE=conan/conan_toolchain.cmake"]
EnvArgs += [f'-DCMAKE_TOOLCHAIN_FILE={str(Path(".").absolute()/"build"/"generators"/"conan_toolchain.cmake")}'] #conan/conan_toolchain.cmake"]
class CMakeCommand(amoeba.CMakeCommand):
def configure_extension(self, ext):
# Ensure Conan dependencies are installed using Conan 2.0 commands
if use_conan:
self.run_conan(ext)
super().configure_extension(ext)
def run_conan(self, ext):
toolchain = str(Path(".").absolute()/"build"/"generators"/"conan_toolchain.cmake")
ext.cmake_configure_options.append(
f"-DCMAKE_TOOLCHAIN_FILE={toolchain}"
)
print("RUNNING CONAN")
# Create the Conan profile and run the Conan install command
subprocess.run([
"conan", "install", ".",
"--build=missing",
])
class BuildOpenSeesRT(amoeba.BuildExtension):
pass
# BuildOpenSeesRT = amoeba.BuildExtension
if __name__ == "__main__":
setuptools.setup(
data_files=[
('bin', [*map(str,Path("win32/").glob("*.*"))]),
] if os.name == "nt" else [],
cmdclass = {
"build_ext": BuildOpenSeesRT, # amoeba.BuildExtension,
"cmake": CMakeCommand
} if build_type != "no-build" else {},
ext_modules = [
amoeba.CMakeExtension(
name = build_type,
install_prefix="opensees",
cmake_build_type=options[build_type][0].split("=")[-1],
cmake_configure_options = [
*EnvArgs,
*options[build_type],
# "-G Ninja",
f"-DOPENSEESRT_VERSION={version}",
*OpenSeesPyRT_Config,
],
cmake_build_options=["-j15",
"--target", "OpenSeesRT",
*OpenSeesPyRT_Target
]
)
] if build_type != "no-build" else []
)