Skip to content

Commit f35afe0

Browse files
authored
get library extension suffix from built-in method (#1036)
1 parent 0004484 commit f35afe0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

deepmd/env.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
import os
5-
import platform
5+
import distutils.ccompiler
66
from configparser import ConfigParser
77
from imp import reload
88
from pathlib import Path
@@ -156,12 +156,8 @@ def get_module(module_name: str) -> "ModuleType":
156156
FileNotFoundError
157157
if module is not found in directory
158158
"""
159-
if platform.system() == "Windows":
160-
ext = ".dll"
161-
elif platform.system() == "Darwin":
162-
ext = ".dylib"
163-
else:
164-
ext = ".so"
159+
# https://discuss.python.org/t/how-to-get-the-file-extension-of-dynamic-libraries-for-current-os/3916/5
160+
ext = distutils.ccompiler.new_compiler().shared_lib_extension
165161

166162
module_file = (
167163
(Path(__file__).parent / SHARED_LIB_MODULE / module_name)

0 commit comments

Comments
 (0)