Skip to content

Commit 4d9531b

Browse files
committed
Correct filenames according to the OS.
1 parent 265a039 commit 4d9531b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

dss_python_backend/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@
66
For better maintenance and evolution of the Python-only code, the module was split in two.
77
'''
88

9-
import os
9+
import os, sys
1010
from . import _altdss_capi_loader
1111
from ._altdss_capi_loader import ffi, lib as loader_lib
1212
from pathlib import Path
1313

1414
altdss_lib_parent_path = Path(_altdss_capi_loader.__file__).absolute().parent
1515

16+
if sys.platform == 'win32':
17+
DLL_SUFFIX = '.dll'
18+
DLL_PREFIX = ''
19+
elif sys.platform in ('linux', 'linux2'):
20+
DLL_SUFFIX = '.so'
21+
DLL_PREFIX = 'lib'
22+
elif sys.platform == 'darwin':
23+
DLL_SUFFIX = '.dylib'
24+
DLL_PREFIX = 'lib'
25+
else:
26+
raise RuntimeError("Unsupported platform!")
27+
1628
if os.environ.get('DSS_EXTENSIONS_DEBUG', '') != '1':
17-
altdss_lib_path = altdss_lib_parent_path.joinpath('libaltdss_capi.so')
29+
altdss_lib_path = altdss_lib_parent_path.joinpath(f'{DLL_PREFIX}altdss_capi{DLL_SUFFIX}')
1830
else:
1931
import warnings
2032
warnings.warn('Environment variable DSS_EXTENSIONS_DEBUG=1 is set: loading the debug version of the DSS C-API library')
21-
altdss_lib_path = altdss_lib_parent_path.joinpath('libaltdss_capid.so')
33+
altdss_lib_path = altdss_lib_parent_path.joinpath(f'{DLL_PREFIX}altdss_capid{DLL_SUFFIX}')
2234

2335
if not altdss_lib_path.exists():
2436
raise RuntimeError('AltDSS library not found!')

0 commit comments

Comments
 (0)