Update __init__.py
This commit is contained in:
@ -6,29 +6,24 @@ import sysconfig
|
|||||||
import ctypes
|
import ctypes
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
library_dir = sysconfig.get_config_vars('LIBDIR')[0]
|
library_dir = sysconfig.get_config_vars('prefix')[0]
|
||||||
library_name = sysconfig.get_config_vars('LIBRARY')[0]
|
py_ver = sysconfig.get_config_vars('VERSION')[0]
|
||||||
library = library_dir + "/" + library_name
|
|
||||||
|
|
||||||
OS_name = platform.system()
|
OS_name = platform.system()
|
||||||
|
|
||||||
if OS_name == "Linux":
|
if OS_name == "Linux":
|
||||||
SHLIB_SUFFIX = '.so'
|
SHLIB_SUFFIX = '.so'
|
||||||
|
library = library_dir + '/lib/' + 'libpython' + py_ver + SHLIB_SUFFIX
|
||||||
elif OS_name == "Darwin":
|
elif OS_name == "Darwin":
|
||||||
SHLIB_SUFFIX = '.dylib'
|
SHLIB_SUFFIX = '.dylib'
|
||||||
|
library = library_dir + '/lib/' + 'libpython' + py_ver + SHLIB_SUFFIX
|
||||||
elif OS_name == "Windows":
|
elif OS_name == "Windows":
|
||||||
SHLIB_SUFFIX = '.dll'
|
SHLIB_SUFFIX = '.dll'
|
||||||
else:
|
library = library_dir + '\\' + 'python' + py_ver + SHLIB_SUFFIX
|
||||||
SHLIB_SUFFIX = sysconfig.get_config_vars('SHLIB_SUFFIX')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pylib = ctypes.CDLL(library)
|
pylib = ctypes.CDLL(library)
|
||||||
except OSError as e:
|
except:
|
||||||
if library.endswith(".a"):
|
OSError
|
||||||
library = library.strip(".a") + SHLIB_SUFFIX
|
|
||||||
pylib = ctypes.CDLL(library)
|
|
||||||
else:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
if not pylib.Py_IsInitialized():
|
if not pylib.Py_IsInitialized():
|
||||||
raise RuntimeError("This interpreter is not compatible with python-based mliap for LAMMPS.")
|
raise RuntimeError("This interpreter is not compatible with python-based mliap for LAMMPS.")
|
||||||
|
|||||||
Reference in New Issue
Block a user