diff --git a/deepmd/env.py b/deepmd/env.py index 4868eb8c3b..92287d8aa5 100644 --- a/deepmd/env.py +++ b/deepmd/env.py @@ -2,7 +2,7 @@ import logging import os -import distutils.ccompiler +import platform from configparser import ConfigParser from imp import reload from pathlib import Path @@ -157,8 +157,12 @@ def get_module(module_name: str) -> "ModuleType": FileNotFoundError if module is not found in directory """ - # 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 + if platform.system() == "Windows": + ext = ".dll" + elif platform.system() == "Darwin": + ext = ".dylib" + else: + ext = ".so" module_file = ( (Path(__file__).parent / SHARED_LIB_MODULE / module_name)