forked from WISDEM/WISDEM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
169 lines (150 loc) · 5.77 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
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env python
# encoding: utf-8
# setup.py
# only if building in place: ``python setup.py build_ext --inplace``
import os
import re
import shutil
import platform
import subprocess
import setuptools
def run_meson_build(staging_dir):
prefix = os.path.join(os.getcwd(), staging_dir)
purelibdir = "."
# check if meson extra args are specified
meson_args = ""
if "MESON_ARGS" in os.environ:
meson_args = os.environ["MESON_ARGS"]
if platform.system() == "Windows":
if not "FC" in os.environ:
os.environ["FC"] = "gfortran"
if not "CC" in os.environ:
os.environ["CC"] = "gcc"
# configure
meson_path = shutil.which("meson")
meson_call = (
f"{meson_path} setup {staging_dir} --prefix={prefix} "
+ f"-Dpython.purelibdir={purelibdir} -Dpython.platlibdir={purelibdir} {meson_args}"
)
sysargs = meson_call.split(" ")
sysargs = [arg for arg in sysargs if arg != ""]
print(sysargs)
p1 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.makedirs(staging_dir, exist_ok=True)
setup_log = os.path.join(staging_dir, "setup.log")
with open(setup_log, "wb") as f:
f.write(p1.stdout)
if p1.returncode != 0:
with open(setup_log, "r") as f:
print(f.read())
raise OSError(sysargs, f"The meson setup command failed! Check the log at {setup_log} for more information.")
# build
meson_call = f"{meson_path} compile -vC {staging_dir}"
sysargs = meson_call.split(" ")
sysargs = [arg for arg in sysargs if arg != ""]
print(sysargs)
p2 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
compile_log = os.path.join(staging_dir, "compile.log")
with open(compile_log, "wb") as f:
f.write(p2.stdout)
if p2.returncode != 0:
with open(compile_log, "r") as f:
print(f.read())
raise OSError(
sysargs, f"The meson compile command failed! Check the log at {compile_log} for more information."
)
def copy_shared_libraries():
build_path = os.path.join(staging_dir, "wisdem")
for root, _dirs, files in os.walk(build_path):
for file in files:
# move wisdem libraries to just under staging_dir
if file.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")):
if ".so.p" in root or ".pyd.p" in root: # excludes intermediate object files
continue
file_path = os.path.join(root, file)
new_path = str(file_path)
match = re.search(staging_dir, new_path)
new_path = new_path[match.span()[1] + 1 :]
print(f"Copying build file {file_path} -> {new_path}")
shutil.copy(file_path, new_path)
if __name__ == "__main__":
# This is where the meson build system will install to, it is then
# used as the sources for setuptools
staging_dir = "meson_build"
# this keeps the meson build system from running more than once
if "dist" not in str(os.path.abspath(__file__)) and not os.path.isdir(staging_dir):
cwd = os.getcwd()
run_meson_build(staging_dir)
os.chdir(cwd)
copy_shared_libraries()
# docs_require = ""
# req_txt = os.path.join("doc", "requirements.txt")
# if os.path.isfile(req_txt):
# with open(req_txt) as f:
# docs_require = f.read().splitlines()
init_file = os.path.join("wisdem", "__init__.py")
# __version__ = re.findall(
# r"""__version__ = ["']+([0-9\.]*)["']+""",
# open(init_file).read(),
# )[0]
setuptools.setup(
name="WISDEM",
version="3.8",
description="Wind-Plant Integrated System Design & Engineering Model",
long_description="""WISDEM is a Python package for conducting multidisciplinary analysis and
optimization of wind turbines and plants. It is built on top of NASA's OpenMDAO library.""",
url="https://github.com/WISDEM/WISDEM",
author="NREL WISDEM Team",
author_email="[email protected]",
install_requires=[
"dearpygui",
"jsonschema",
"marmot-agents>=0.2.5",
"numpy",
"openmdao>=3.18",
"openpyxl",
"nlopt",
"pandas",
"pydoe2",
"python-benedict",
"pyyaml",
"ruamel.yaml",
"scipy",
"simpy",
"sortedcontainers",
"statsmodels",
],
extras_require={
"testing": ["pytest"],
},
python_requires=">=3.8",
package_data={"": ["*.yaml", "*.xlsx", "*.txt", "*.so", "*.lib", "*.pyd", "*.pdb", "*.dylib", "*.dll"]},
# package_dir = {'': 'wisdem'},
packages=setuptools.find_packages(exclude=["docs", "tests", "ext"]),
license="Apache License, Version 2.0",
entry_points={
"console_scripts": [
"wisdem=wisdem.main:wisdem_cmd",
"compare_designs=wisdem.postprocessing.compare_designs:main",
],
},
zip_safe=False,
)
# os.environ['NPY_DISTUTILS_APPEND_FLAGS'] = '1'
# bemExt = Extension(
# "wisdem.ccblade._bem",
# sources=[os.path.join("wisdem", "ccblade", "src", "bem.f90")],
# extra_compile_args=["-O2", "-fPIC", "-std=c11"],
# )
# pyframeExt = Extension(
# "wisdem.pyframe3dd._pyframe3dd",
# sources=glob.glob(os.path.join("wisdem", "pyframe3dd", "src", "*.c")),
# extra_compile_args=["-O2", "-fPIC", "-std=c11"],
# )
# precompExt = Extension(
# "wisdem.rotorse._precomp",
# sources=[os.path.join("wisdem", "rotorse", "PreCompPy.f90")],
# extra_compile_args=["-O2", "-fPIC", "-std=c11"],
# )
# Top-level setup
# ext_modules=[bemExt, pyframeExt, precompExt],