Skip to content

Commit 8d412f2

Browse files
authored
Merge branch 'OpenModelica:master' into use_logging_in_ModelicaSystem_syntron
2 parents 7916694 + dbe2119 commit 8d412f2

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

OMPython/__init__.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -947,25 +947,18 @@ def _run_cmd(self, cmd: list):
947947

948948
if platform.system() == "Windows":
949949
omhome = os.path.join(os.environ.get("OPENMODELICAHOME"))
950-
dllPath = (os.path.join(omhome, "bin")
951-
+ os.pathsep + os.path.join(omhome, "lib/omc")
952-
+ os.pathsep + os.path.join(omhome, "lib/omc/cpp")
953-
+ os.pathsep + os.path.join(omhome, "lib/omc/omsicpp"))
954-
955-
# include path to resources of defined external libraries
956-
for element in self.lmodel:
957-
if element is not None:
958-
if isinstance(element, str):
959-
if element.endswith("package.mo"):
960-
pkgpath = element[:-10] + '/Resources/Library/'
961-
for wver in ['win32', 'win64']:
962-
pkgpath_wver = pkgpath + '/' + wver
963-
if os.path.exists(pkgpath_wver):
964-
dllPath = pkgpath_wver + os.pathsep + dllPath
965-
966-
# fix backslash in path definitions
967-
dllPath = dllPath.replace("\\", "/")
968-
950+
dllPath = ""
951+
952+
## set the process environment from the generated .bat file in windows which should have all the dependencies
953+
batFilePath = os.path.join(self.tempdir, '{}.{}'.format(self.modelName, "bat")).replace("\\", "/")
954+
if (not os.path.exists(batFilePath)):
955+
print("Error: bat does not exist " + batFilePath)
956+
957+
with open(batFilePath, 'r') as file:
958+
for line in file:
959+
match = re.match(r"^SET PATH=([^%]*)", line, re.IGNORECASE)
960+
if match:
961+
dllPath = match.group(1).strip(';') # Remove any trailing semicolons
969962
my_env = os.environ.copy()
970963
my_env["PATH"] = dllPath + os.pathsep + my_env["PATH"]
971964
else:

0 commit comments

Comments
 (0)