From 14a6d5e8806c7fb7190b5c5d90107f07cb11bbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Simon?= <tamas.simon@alphacruncher.com> Date: Tue, 17 Dec 2024 12:42:48 +0000 Subject: [PATCH] Added native win64 support: fixed path handling and Tasmanian dll reference --- src/dynare/dynare.py | 4 +++- src/dynare/dynare_context.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dynare/dynare.py b/src/dynare/dynare.py index f1cb45b..b4888de 100644 --- a/src/dynare/dynare.py +++ b/src/dynare/dynare.py @@ -14,7 +14,9 @@ def dynare(model: str | Path) -> Context: model = Path(model) jl.seval("using Serialization") jl.seval("using Dynare") - jl.seval(f'@dynare "{model.resolve()}"') + # Double-escape '\' as julia will also interpret the string. Only relevant on Windows + resolved_path = str(model.resolve()).replace("\\", "\\\\") + jl.seval(f'@dynare "{resolved_path}"') jls_path = model.parent / model.stem / "output" / f"{model.stem}.jls" diff --git a/src/dynare/dynare_context.py b/src/dynare/dynare_context.py index aa7710c..a6d5d7d 100644 --- a/src/dynare/dynare_context.py +++ b/src/dynare/dynare_context.py @@ -746,7 +746,11 @@ class PySGSolver(Enum): ) -TASlib = ctypes.CDLL(os.getenv("LIBTASMANIAN_PATH")) # Load the shared library +libtas_path = os.getenv("LIBTASMANIAN_PATH") +if libtas_path: + TASlib = ctypes.CDLL(libtas_path) # Load the shared library +else: + TASlib = None @dataclass @@ -770,6 +774,8 @@ class PyTasmanianSG: @classmethod def from_julia(cls, jl_tasmaniansg) -> Self: + if not TASlib: + raise ValueError("It looks like Tasmanian is not installed. Please install from https://github.com/ORNL/TASMANIAN and set LIBTASMANIAN_PATH") c_func = getattr(TASlib, "tsgConstructTasmanianSparseGrid") c_func.restype = ctypes.POINTER(ctypes.c_void_p) pGrid = c_func() -- GitLab