Skip to content

Commit

Permalink
Support for loading sunvox.dll in win32 environment
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewryanscott committed Oct 21, 2016
1 parent b98cf90 commit 487a00d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions sunvox/dll.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
`sv_init` becomes `init`
"""

from ctypes import POINTER, Structure, cdll, c_char_p, c_int, c_short, c_ubyte, c_ushort, c_uint, c_void_p
from ctypes import POINTER, Structure, cdll, c_char_p, c_int, c_short, c_ubyte, c_ushort, c_uint, c_void_p, windll
from ctypes.util import find_library
from enum import IntEnum
import os
Expand All @@ -29,6 +29,7 @@
DLL_PATH = os.environ.get('SUNVOX_DLL_PATH')


loader = cdll
if DLL_PATH is not None:
_sunvox_lib_path = DLL_PATH
elif DLL_BASE is not None:
Expand All @@ -39,15 +40,21 @@
('darwin', True): 'osx/lib_x86_64/sunvox.dylib',
('linux', True): 'linux/lib_x86_64/sunvox.so',
('linux', False): 'linux/lib_x86/sunvox.so',
('win32', False): 'windows/lib_x86/sunvox.dll',
('win32', False): 'sunvox',
}.get(key)
if rel_path is not None:
_sunvox_lib_path = os.path.join(DLL_BASE, rel_path)
if sys.platform == 'win32':
_lib_path = os.path.join(DEFAULT_DLL_BASE, 'windows', 'lib_x86')
os.environ['PATH'] = _lib_path + ';' + os.environ['PATH']
_sunvox_lib_path = rel_path
loader = windll
else:
raise NotImplementedError('SunVox DLL could not be found for your platform.')
if rel_path is not None:
_sunvox_lib_path = os.path.join(DLL_BASE, rel_path)
else:
raise NotImplementedError('SunVox DLL could not be found for your platform.')
else:
_sunvox_lib_path = find_library('sunvox')
_s = cdll.LoadLibrary(_sunvox_lib_path)
_s = loader.LoadLibrary(_sunvox_lib_path)


class NOTECMD(IntEnum):
Expand Down

0 comments on commit 487a00d

Please sign in to comment.