Skip to content

Commit 79d6c67

Browse files
authored
fix mono set dirs (#48)
* fix mono set dirs * fix path
1 parent a56d77c commit 79d6c67

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

clr_loader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_mono(
7070

7171
libmono = _maybe_path(libmono)
7272
if libmono is None:
73-
libmono = find_libmono(sgen=sgen)
73+
libmono = find_libmono(sgen=sgen, assembly_dir=assembly_dir)
7474

7575
impl = Mono(
7676
# domain=domain,

clr_loader/mono.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def initialize(
136136
_MONO = load_mono(libmono)
137137

138138
if assembly_dir is not None and config_dir is not None:
139-
_MONO.mono_set_dirs(assembly_dir, config_dir)
139+
_MONO.mono_set_dirs(assembly_dir.encode("utf8"), config_dir.encode("utf8"))
140140

141141
# Load in global config (i.e /etc/mono/config)
142142
global_encoded = global_config_file or ffi.NULL

clr_loader/util/find.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def find_runtimes() -> Iterator[DotnetCoreRuntimeSpec]:
105105
return find_runtimes_in_root(dotnet_root)
106106

107107

108-
def find_libmono(*, sgen: bool = True) -> Path:
108+
def find_libmono(*, assembly_dir: str = None, sgen: bool = True) -> Path:
109109
"""Find a suitable libmono dynamic library
110110
111111
On Windows and macOS, we check the default installation directories.
@@ -137,9 +137,12 @@ def find_libmono(*, sgen: bool = True) -> Path:
137137
)
138138

139139
else:
140-
from ctypes.util import find_library
141-
142-
path = find_library(unix_name)
140+
if assembly_dir == None:
141+
from ctypes.util import find_library
142+
path = find_library(unix_name)
143+
else:
144+
libname = "lib" + unix_name + ".so"
145+
path = Path(assembly_dir) / "lib" / libname
143146

144147
if path is None:
145148
raise RuntimeError("Could not find libmono")

0 commit comments

Comments
 (0)