13
13
import urllib .request
14
14
import zipfile
15
15
import shutil
16
+ import pathlib
16
17
17
18
# Set up logging
18
19
log_file = 'build_log.txt'
@@ -51,49 +52,9 @@ def run(self):
51
52
52
53
logging .info ("Checking for required dependencies..." )
53
54
54
-
55
- # List of required dependencies
56
- # dependencies = ["cmake", "make", "gcc", "g++"]
57
- #
58
- # # Check each dependency and attempt installation if missing
59
- # for dep in dependencies:
60
- # try:
61
- # subprocess.check_call([dep, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
62
- # logging.info(f"{dep} is installed.")
63
- # except:
64
- # logging.warning(f"{dep} is not installed. Attempting to install...")
65
- # try:
66
- # # Install dependency using apt-get (Debian/Ubuntu)
67
- # subprocess.check_call(["sudo", "apt-get", "update"])
68
- # subprocess.check_call(["sudo", "apt-get", "install", "-y", dep])
69
- # logging.info(f"Successfully installed {dep}.")
70
- # except:
71
- # logging.error(f"Failed to install {dep}. Please install it manually")
72
-
73
- dependencies = ["cmake" , "gcc" , "make" ]
74
-
75
- for dep in dependencies :
76
- try :
77
- subprocess .check_call ([dep , "--version" ], stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
78
- logging .info (f"{ dep } is installed." )
79
- except :
80
- logging .warning (f"{ dep } is not installed. Attempting to install..." )
81
- try :
82
- # First try winget
83
- subprocess .check_call (["winget" , "install" , "-e" , "--id" , f"{ dep } " ])
84
- logging .info (f"Successfully installed { dep } using winget." )
85
- except :
86
- logging .warning (f"winget failed to install { dep } . Trying choco..." )
87
- try :
88
- subprocess .check_call (["choco" , "install" , dep , "-y" ])
89
- logging .info (f"Successfully installed { dep } using choco." )
90
- except :
91
- logging .error (f"Failed to install { dep } . Please install it manually" )
92
-
93
- logging .info (f"OpenDSS source folder '{ source_dir } ' not found. Downloading from { download_url } ..." )
94
-
95
55
# Check if the OpenDSS source code is available; if not, download it
96
56
if not os .path .exists (source_dir ):
57
+ logging .info (f"OpenDSS source folder '{ source_dir } ' not found. Downloading from { download_url } ..." )
97
58
self .download_source_code ()
98
59
99
60
# Create a build directory if it doesn't exist
@@ -164,17 +125,17 @@ def build_opendss(self):
164
125
logging .info (f"Running CMake command: { ' ' .join (cmake_command )} in { build_folder } " )
165
126
# subprocess.check_call(cmake_command, cwd=build_folder)
166
127
result = subprocess .run (cmake_command , cwd = build_folder , capture_output = True , text = True , shell = True )
167
- logging .info (f"{ result .stdout } " )
168
- logging .info (f"{ result .stderr } " )
128
+ # logging.info(f"{result.stdout}")
129
+ # logging.info(f"{result.stderr}")
169
130
logging .info ("CMake configuration completed successfully." )
170
131
171
132
# Step 4: Compile
172
133
compile_command = [r"C:\Program Files\CMake\bin\cmake.exe" , "--build" , "." , "-j" , "4" ]
173
134
logging .info (f"Running compilation command: { ' ' .join (compile_command )} in { build_folder } " )
174
135
# subprocess.check_call(compile_command, cwd=build_folder)
175
136
result = subprocess .run (compile_command , cwd = build_folder , capture_output = True , text = True , shell = True )
176
- logging .info (f"{ result .stdout } " )
177
- logging .info (f"{ result .stderr } " )
137
+ # logging.info(f"{result.stdout}")
138
+ # logging.info(f"{result.stderr}")
178
139
logging .info ("OpenDSS build completed successfully." )
179
140
180
141
# Define the target directory for the compiled library
@@ -184,6 +145,7 @@ def build_opendss(self):
184
145
os .makedirs (target_lib_dir )
185
146
logging .info (f"Created target directory: { target_lib_dir } " )
186
147
148
+ build_folder = pathlib .Path (build_folder ).joinpath ("Debug" )
187
149
# Move all files from the build folder to the target directory
188
150
logging .info (f"Moving all files from { build_folder } to { target_lib_dir } " )
189
151
for filename in os .listdir (build_folder ):
@@ -231,6 +193,7 @@ def read(*names, **kwargs):
231
193
'opendss_official/windows/cpp/x64/*.dll' ,
232
194
'opendss_official/windows/cpp/x86/*.dll' ,
233
195
'opendss_official/linux/cpp/*.so' ,
196
+ 'opendss_official/linux/cpp/*.dll' ,
234
197
]
235
198
},
236
199
py_modules = [splitext (basename (path ))[0 ] for path in glob ('src/*.py' )],
@@ -266,8 +229,8 @@ def read(*names, **kwargs):
266
229
extras_require = {
267
230
"dev" : ["pytest" , "pytest-cov" , "sphinx-rtd-theme" , "nbsphinx" , "black" , "pre-commit" , "tox" , "twine" , "ipython" , "flake8" ],
268
231
},
269
- cmdclass = {
270
- 'build_opendss_linux' : BuildOpenDSSLinux ,
271
- 'install' : CustomInstallCommand , # Custom install command
272
- },
232
+ # cmdclass={
233
+ # 'build_opendss_linux': BuildOpenDSSLinux,
234
+ # 'install': CustomInstallCommand, # Custom install command
235
+ # },
273
236
)
0 commit comments