Closed clagms closed 8 months ago
Also, a minor request, but it would be nice if the working directory could be restored in case there's an exception loading the DLL. Currently the code leaves the working directory in an inconsistent state, which breaks all code upstream 😋
I am getting an error loading an FMU from a directory using a relative path.
Here's the code on my side:
I think the problem is that
fmucontroller_path
is a relative path, and I think the issue is that the following fmpy code assumes that the path for the FMU is an absolute one:The problem occurs when
self.dll = cdll.LoadLibrary(libraryPath)
gets called with a relative path (model/binaries/win64/unifmu.dll
) but the current working directory ismodel/binaries/win64
. This makes the loader look for a librarymodel/binaries/win64/unifmu.dll
insidemodel/binaries/win64/
which naturally leads to the following exception:I think the solution is to check if the path is relative, and then adjust the path of the loaded DLL accordingly.
Thanks for all the great work @t-sommer !