Skip to content

Commit

Permalink
Merge pull request #247 from fixstars/fix/windows-dll-import-conflict
Browse files Browse the repository at this point in the history
fix dll conflict
  • Loading branch information
iitaku authored Feb 27, 2024
2 parents e9e40f0 + 0d2e08b commit 17f645c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
9 changes: 2 additions & 7 deletions python/ionpy/Builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import ctypes
from typing import Optional
from ctypes.util import find_library
import os

from .native import (
c_ion_builder_t,
Expand All @@ -20,6 +17,7 @@

ion_builder_run,
ion_builder_run_with_port_map,

)

from .Node import Node
Expand Down Expand Up @@ -49,10 +47,7 @@ def set_target(self, target: str) -> 'Builder':
return self

def with_bb_module(self, path: str) -> 'Builder':
if os.name == 'nt':
ret = ion_builder_with_bb_module(self.obj, str(find_library(path)).encode())
else:
ret = ion_builder_with_bb_module(self.obj, path.encode())
ret = ion_builder_with_bb_module(self.obj,path.encode())
if ret != 0:
raise Exception('Invalid operation')

Expand Down
8 changes: 3 additions & 5 deletions python/ionpy/native.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import ctypes
from ctypes.util import find_library

import os
import platform

pre_built_path = os.path.join(os.path.dirname(__file__), 'module')

if platform.system() == 'Windows':
ion_core_module = find_library('ion-core.dll')
ion_core_module = os.path.join(pre_built_path, 'windows/ion-core.dll')
ion_bb_module = os.path.join(pre_built_path, 'windows/ion-bb.dll')
elif platform.system() == 'Darwin':
ion_core_module = os.path.join(pre_built_path, 'macos/libion-core.dylib')
ion_bb_module = os.path.join(pre_built_path, 'macos/libion-bb.dylib')
Expand All @@ -19,8 +18,7 @@
# ion-core.dll must be in a directory listed in %PATH%.
# libion-core.dylib must be in a directory listed in $DYLD_LIBRARY_PATH.
ion_core = ctypes.cdll.LoadLibrary(ion_core_module)
if not platform.system() == 'Windows':
ion_bb = ctypes.cdll.LoadLibrary(ion_bb_module)
ion_bb = ctypes.cdll.LoadLibrary(ion_bb_module)

class c_ion_type_t(ctypes.Structure):
_fields_ = [
Expand Down
2 changes: 1 addition & 1 deletion python/ionpy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.5.0"
__version__ = "1.6.0"

0 comments on commit 17f645c

Please sign in to comment.