From 196b1dc16ea3d5492538be3bfe908e5a97b24a4e Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 25 Aug 2021 19:40:55 -0400 Subject: [PATCH] get library extension suffix from built-in method (#1036) --- deepmd/env.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/deepmd/env.py b/deepmd/env.py index ace9d3b76e..aaa148b357 100644 --- a/deepmd/env.py +++ b/deepmd/env.py @@ -2,7 +2,7 @@ import logging import os -import platform +import distutils.ccompiler from configparser import ConfigParser from imp import reload from pathlib import Path @@ -156,12 +156,8 @@ def get_module(module_name: str) -> "ModuleType": FileNotFoundError if module is not found in directory """ - if platform.system() == "Windows": - ext = ".dll" - elif platform.system() == "Darwin": - ext = ".dylib" - else: - ext = ".so" + # https://discuss.python.org/t/how-to-get-the-file-extension-of-dynamic-libraries-for-current-os/3916/5 + ext = distutils.ccompiler.new_compiler().shared_lib_extension module_file = ( (Path(__file__).parent / SHARED_LIB_MODULE / module_name)