From f92259b68b0223911d0ad308b63920f402f856c0 Mon Sep 17 00:00:00 2001 From: Daniel Van Der Maden Date: Thu, 24 Sep 2020 17:44:35 -0700 Subject: [PATCH] [cli] Update lib linking for darwin only case --- pyhmy/cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pyhmy/cli.py b/pyhmy/cli.py index 6e65676..060eefa 100644 --- a/pyhmy/cli.py +++ b/pyhmy/cli.py @@ -368,15 +368,16 @@ def download(path="./bin/hmy", replace=True, verbose=True): os.chdir(old_cwd) env = os.environ.copy() - files_in_parent_dir = set(os.listdir(parent_dir)) - if files_in_parent_dir.intersection(_libs) == _libs: - if sys.platform.startswith("linux"): - env["LD_LIBRARY_PATH"] = parent_dir - else: - env["DYLD_FALLBACK_LIBRARY_PATH"] = parent_dir - elif os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/bls") \ - and os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/mcl"): - env.update(get_bls_build_variables()) - else: - raise RuntimeWarning(f"Could not get environment for downloaded hmy CLI at `{path}`") + if sys.platform.startswith("darwin"): # Dynamic linking for darwin + try: + files_in_parent_dir = set(os.listdir(parent_dir)) + if files_in_parent_dir.intersection(_libs) == _libs: + env["DYLD_FALLBACK_LIBRARY_PATH"] = parent_dir + elif os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/bls") \ + and os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/mcl"): + env.update(get_bls_build_variables()) + else: + raise RuntimeWarning(f"Could not get environment for downloaded hmy CLI at `{path}`") + except Exception as e: + raise RuntimeWarning(f"Could not get environment for downloaded hmy CLI at `{path}`") from e return env