Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dylib loading for Darwin, and fix relative dllpath #85

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions epanet-module/epamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

added function ENsimtime"""


import sys
import os
import ctypes
import platform
import datetime

this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(this_dir)

_plat= platform.system()
if _plat=='Linux':
_lib = ctypes.CDLL("libepanet2.so.2")
elif _plat=='Windows':
try:
# if epanet2.dll compiled with __cdecl (as in OpenWaterAnalytics)
_lib = ctypes.CDLL("epamodule\epanet2.dll")
_lib = ctypes.CDLL(os.path.join(this_dir, "epamodule", "epanet2.dll"))
_lib.ENgetversion(ctypes.byref(ctypes.c_int()))
except ValueError:
# if epanet2.dll compiled with __stdcall (as in EPA original DLL)
Expand All @@ -22,7 +26,8 @@
_lib.ENgetversion(ctypes.byref(ctypes.c_int()))
except ValueError:
raise Exception("epanet2.dll not suitable")

elif _plat=='Darwin':
_lib = ctypes.CDLL(os.path.join(this_dir, "epamodule", "libepanet2.dylib"))
else:
Exception('Platform '+ _plat +' unsupported (not yet)')

Expand Down