use different file name of BMap in PyBMap for different system

This commit is contained in:
yyc12345 2023-11-16 21:11:36 +08:00
parent 7c6dd463bd
commit 562b44c7aa
4 changed files with 31 additions and 6 deletions

View File

@ -1,6 +1,9 @@
# my ban # my ban
*.dll *.dll
*.pdb *.pdb
*.so
*.dylib
*.bin
testbench.py testbench.py
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

View File

@ -1,4 +1,4 @@
import ctypes, os import ctypes, os, sys
#region Type Defines #region Type Defines
@ -67,10 +67,21 @@ bm_VxMatrix_p = ctypes.POINTER(bm_VxMatrix)
#region BMap Loader #region BMap Loader
_g_BMapLibName: str
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
_g_BMapLibName = "BMap.dll"
elif sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
_g_BMapLibName = "BMap.so"
elif sys.platform.startswith('darwin'):
_g_BMapLibName = "BMap.dylib"
else:
_g_BMapLibName = "BMap.bin"
_g_BMapModule: ctypes.CDLL = None _g_BMapModule: ctypes.CDLL = None
try: try:
_g_BMapModule = ctypes.cdll.LoadLibrary( _g_BMapModule = ctypes.cdll.LoadLibrary(
os.path.join(os.path.dirname(__file__), "BMap.dll") os.path.join(os.path.dirname(__file__), _g_BMapLibName)
) )
except: except:
_g_BMapModule = None _g_BMapModule = None

View File

@ -2,5 +2,5 @@
The real scripts are placed in sub PyBMap folder. This folder is served for testbench scripts placing. The real scripts are placed in sub PyBMap folder. This folder is served for testbench scripts placing.
Place any testbench files (e.g. `testbench.py`) in there what you want and don't sumbit them. Place any testbench files (e.g. `testbench.py`) in there what you want and don't sumbit them.
The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them. The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them.
The native BMap library must be named as `BMap.dll` in any platforms (e.g. Linux, macOS). Do not change name to `BMap.so` or `BMap.dylib`. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.

View File

@ -1,4 +1,4 @@
import ctypes, os import ctypes, os, sys
#region Type Defines #region Type Defines
@ -67,10 +67,21 @@ bm_VxMatrix_p = ctypes.POINTER(bm_VxMatrix)
#region BMap Loader #region BMap Loader
_g_BMapLibName: str
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
_g_BMapLibName = "BMap.dll"
elif sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
_g_BMapLibName = "BMap.so"
elif sys.platform.startswith('darwin'):
_g_BMapLibName = "BMap.dylib"
else:
_g_BMapLibName = "BMap.bin"
_g_BMapModule: ctypes.CDLL = None _g_BMapModule: ctypes.CDLL = None
try: try:
_g_BMapModule = ctypes.cdll.LoadLibrary( _g_BMapModule = ctypes.cdll.LoadLibrary(
os.path.join(os.path.dirname(__file__), "BMap.dll") os.path.join(os.path.dirname(__file__), _g_BMapLibName)
) )
except: except:
_g_BMapModule = None _g_BMapModule = None