From c6ea057390cacb5fbf1dbdf5a19a3012e4158d88 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Tue, 10 Jan 2023 12:38:23 -0600 Subject: [PATCH 1/2] fix mono set dirs --- clr_loader/__init__.py | 2 +- clr_loader/mono.py | 2 +- clr_loader/util/find.py | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clr_loader/__init__.py b/clr_loader/__init__.py index 4b08148..aa604ad 100644 --- a/clr_loader/__init__.py +++ b/clr_loader/__init__.py @@ -70,7 +70,7 @@ def get_mono( libmono = _maybe_path(libmono) if libmono is None: - libmono = find_libmono(sgen=sgen) + libmono = find_libmono(sgen=sgen, assembly_dir=assembly_dir) impl = Mono( # domain=domain, diff --git a/clr_loader/mono.py b/clr_loader/mono.py index 158ddb7..7c3f20d 100644 --- a/clr_loader/mono.py +++ b/clr_loader/mono.py @@ -136,7 +136,7 @@ def initialize( _MONO = load_mono(libmono) if assembly_dir is not None and config_dir is not None: - _MONO.mono_set_dirs(assembly_dir, config_dir) + _MONO.mono_set_dirs(assembly_dir.encode("utf8"), config_dir.encode("utf8")) # Load in global config (i.e /etc/mono/config) global_encoded = global_config_file or ffi.NULL diff --git a/clr_loader/util/find.py b/clr_loader/util/find.py index d5d7b89..189faa9 100644 --- a/clr_loader/util/find.py +++ b/clr_loader/util/find.py @@ -105,7 +105,7 @@ def find_runtimes() -> Iterator[DotnetCoreRuntimeSpec]: return find_runtimes_in_root(dotnet_root) -def find_libmono(*, sgen: bool = True) -> Path: +def find_libmono(*, assembly_dir: str = None, sgen: bool = True) -> Path: """Find a suitable libmono dynamic library On Windows and macOS, we check the default installation directories. @@ -137,9 +137,11 @@ def find_libmono(*, sgen: bool = True) -> Path: ) else: - from ctypes.util import find_library - - path = find_library(unix_name) + if assembly_dir == None: + from ctypes.util import find_library + path = find_library(unix_name) + else: + path = os.path.join(assembly_dir, "lib" + unix_name + ".so") if path is None: raise RuntimeError("Could not find libmono") From 26e346fb01fb2e693fb191b4f0c17bedd46341af Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Tue, 10 Jan 2023 12:45:29 -0600 Subject: [PATCH 2/2] fix path --- clr_loader/util/find.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clr_loader/util/find.py b/clr_loader/util/find.py index 189faa9..6ef7bc3 100644 --- a/clr_loader/util/find.py +++ b/clr_loader/util/find.py @@ -141,7 +141,8 @@ def find_libmono(*, assembly_dir: str = None, sgen: bool = True) -> Path: from ctypes.util import find_library path = find_library(unix_name) else: - path = os.path.join(assembly_dir, "lib" + unix_name + ".so") + libname = "lib" + unix_name + ".so" + path = Path(assembly_dir) / "lib" / libname if path is None: raise RuntimeError("Could not find libmono")