Skip to content

Commit

Permalink
fix mono set dirs (#48)
Browse files Browse the repository at this point in the history
* fix mono set dirs

* fix path
  • Loading branch information
koubaa authored Jan 13, 2023
1 parent a56d77c commit 79d6c67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clr_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clr_loader/mono.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions clr_loader/util/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -137,9 +137,12 @@ 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:
libname = "lib" + unix_name + ".so"
path = Path(assembly_dir) / "lib" / libname

if path is None:
raise RuntimeError("Could not find libmono")
Expand Down

0 comments on commit 79d6c67

Please sign in to comment.