From ab8c38a3a9b81388bbe13bbc552f2cf6819a945a Mon Sep 17 00:00:00 2001 From: Dong-Geon Lee Date: Fri, 11 Nov 2022 18:57:46 +0900 Subject: [PATCH 1/2] Find dotnet root using architecture name --- clr_loader/util/find.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clr_loader/util/find.py b/clr_loader/util/find.py index 22ba843..38bb306 100644 --- a/clr_loader/util/find.py +++ b/clr_loader/util/find.py @@ -1,5 +1,6 @@ import os import os.path +import platform import shutil import sys from pathlib import Path @@ -42,10 +43,10 @@ def find_dotnet_root() -> Path: prog_files = Path(prog_files) dotnet_root = prog_files / "dotnet" elif sys.platform == "darwin": - if sys.maxsize > 2**32: # is_64bits - dotnet_root = Path("/usr/local/share/dotnet/x64") - else: + if "ARM" in platform.machine().upper(): dotnet_root = Path("/usr/local/share/dotnet") + else: + dotnet_root = Path("/usr/local/share/dotnet/x64") if dotnet_root is not None and dotnet_root.is_dir(): return dotnet_root From c29d3af40b53564fd8ca8c2b8a175bb89e261c5c Mon Sep 17 00:00:00 2001 From: DongGeon Lee Date: Sun, 18 Dec 2022 15:29:45 +0900 Subject: [PATCH 2/2] Iterate dotnet root candidates --- clr_loader/util/find.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clr_loader/util/find.py b/clr_loader/util/find.py index 38bb306..e6b4d13 100644 --- a/clr_loader/util/find.py +++ b/clr_loader/util/find.py @@ -43,10 +43,14 @@ def find_dotnet_root() -> Path: prog_files = Path(prog_files) dotnet_root = prog_files / "dotnet" elif sys.platform == "darwin": - if "ARM" in platform.machine().upper(): - dotnet_root = Path("/usr/local/share/dotnet") - else: - dotnet_root = Path("/usr/local/share/dotnet/x64") + dotnet_exec_paths = ( + Path("/usr/local/share/dotnet/dotnet"), + Path("/usr/local/share/dotnet/x64/dotnet")) + + for dotnet_exec in dotnet_exec_paths: + if dotnet_exec.is_file(): + dotnet_root = dotnet_exec.parent.absolute() + break if dotnet_root is not None and dotnet_root.is_dir(): return dotnet_root