Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mono set dirs #48

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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