diff --git a/wntr/epanet/Darwin/libepanet.dylib b/wntr/epanet/Darwin/libepanet.dylib deleted file mode 100755 index bb961b4c0..000000000 Binary files a/wntr/epanet/Darwin/libepanet.dylib and /dev/null differ diff --git a/wntr/epanet/Darwin/libepanet2.dylib b/wntr/epanet/Darwin/libepanet2.dylib deleted file mode 100755 index 5a458ddf3..000000000 Binary files a/wntr/epanet/Darwin/libepanet2.dylib and /dev/null differ diff --git a/wntr/epanet/Darwin/libepanet22.dylib b/wntr/epanet/Darwin/libepanet22.dylib deleted file mode 100755 index 1f6813f29..000000000 Binary files a/wntr/epanet/Darwin/libepanet22.dylib and /dev/null differ diff --git a/wntr/epanet/Linux/libepanet22_amd64.so b/wntr/epanet/Linux/libepanet22_amd64.so deleted file mode 100755 index d0da2ba2e..000000000 Binary files a/wntr/epanet/Linux/libepanet22_amd64.so and /dev/null differ diff --git a/wntr/epanet/Linux/libepanet2_amd64.so b/wntr/epanet/Linux/libepanet2_amd64.so deleted file mode 100644 index 5c01d83fd..000000000 Binary files a/wntr/epanet/Linux/libepanet2_amd64.so and /dev/null differ diff --git a/wntr/epanet/Windows/epanet2.dll b/wntr/epanet/Windows/epanet2.dll deleted file mode 100644 index 544c41872..000000000 Binary files a/wntr/epanet/Windows/epanet2.dll and /dev/null differ diff --git a/wntr/epanet/Windows/epanet22_amd64.dll b/wntr/epanet/Windows/epanet22_amd64.dll deleted file mode 100644 index 5b4a7a182..000000000 Binary files a/wntr/epanet/Windows/epanet22_amd64.dll and /dev/null differ diff --git a/wntr/epanet/Windows/epanet22_win32.dll b/wntr/epanet/Windows/epanet22_win32.dll deleted file mode 100644 index f91a2aff8..000000000 Binary files a/wntr/epanet/Windows/epanet22_win32.dll and /dev/null differ diff --git a/wntr/epanet/Windows/epanet2_amd64.dll b/wntr/epanet/Windows/epanet2_amd64.dll deleted file mode 100644 index 8a5a9e261..000000000 Binary files a/wntr/epanet/Windows/epanet2_amd64.dll and /dev/null differ diff --git a/wntr/epanet/Windows/epanetmsx.dll b/wntr/epanet/Windows/epanetmsx.dll deleted file mode 100644 index ee5ffc253..000000000 Binary files a/wntr/epanet/Windows/epanetmsx.dll and /dev/null differ diff --git a/wntr/epanet/libepanet/darwin-arm/libepanet2.dylib b/wntr/epanet/libepanet/darwin-arm/libepanet2.dylib new file mode 100644 index 000000000..a446a9999 Binary files /dev/null and b/wntr/epanet/libepanet/darwin-arm/libepanet2.dylib differ diff --git a/wntr/epanet/Darwin/libepanetmsx.dylib b/wntr/epanet/libepanet/darwin-arm/libepanetmsx.dylib old mode 100755 new mode 100644 similarity index 100% rename from wntr/epanet/Darwin/libepanetmsx.dylib rename to wntr/epanet/libepanet/darwin-arm/libepanetmsx.dylib diff --git a/wntr/epanet/libepanet/darwin-x64/libepanet2.dylib b/wntr/epanet/libepanet/darwin-x64/libepanet2.dylib new file mode 100644 index 000000000..e3d7f1009 Binary files /dev/null and b/wntr/epanet/libepanet/darwin-x64/libepanet2.dylib differ diff --git a/wntr/epanet/libepanet/darwin-x64/libepanetmsx.dylib b/wntr/epanet/libepanet/darwin-x64/libepanetmsx.dylib new file mode 100644 index 000000000..361bac217 Binary files /dev/null and b/wntr/epanet/libepanet/darwin-x64/libepanetmsx.dylib differ diff --git a/wntr/epanet/Linux/libepanet2.so b/wntr/epanet/libepanet/linux-x64/libepanet2.so similarity index 100% rename from wntr/epanet/Linux/libepanet2.so rename to wntr/epanet/libepanet/linux-x64/libepanet2.so diff --git a/wntr/epanet/Linux/libepanetmsx.so b/wntr/epanet/libepanet/linux-x64/libepanetmsx.so similarity index 100% rename from wntr/epanet/Linux/libepanetmsx.so rename to wntr/epanet/libepanet/linux-x64/libepanetmsx.so diff --git a/wntr/epanet/libepanet/windows-x64/epanet2.dll b/wntr/epanet/libepanet/windows-x64/epanet2.dll new file mode 100644 index 000000000..658d0494a Binary files /dev/null and b/wntr/epanet/libepanet/windows-x64/epanet2.dll differ diff --git a/wntr/epanet/libepanet/windows-x64/epanetmsx.dll b/wntr/epanet/libepanet/windows-x64/epanetmsx.dll new file mode 100644 index 000000000..604bbb496 Binary files /dev/null and b/wntr/epanet/libepanet/windows-x64/epanetmsx.dll differ diff --git a/wntr/epanet/msx/toolkit.py b/wntr/epanet/msx/toolkit.py index 10070283b..63d4aeea2 100644 --- a/wntr/epanet/msx/toolkit.py +++ b/wntr/epanet/msx/toolkit.py @@ -9,6 +9,7 @@ licensed under the BSD license. See LICENSE.md for details. """ import ctypes +import logging import os import os.path import platform @@ -20,29 +21,35 @@ from wntr.epanet.msx.enums import TkObjectType, TkSourceType from ..toolkit import ENepanet -from .exceptions import MSX_ERROR_CODES, EpanetMsxException, MSXKeyError, MSXValueError +from .exceptions import (MSX_ERROR_CODES, EpanetMsxException, MSXKeyError, + MSXValueError) + +logger = logging.getLogger(__name__) epanet_toolkit = "wntr.epanet.toolkit" if os.name in ["nt", "dos"]: - libepanet = resource_filename(__name__, "../Windows/epanet2.dll") - libmsx = resource_filename(__name__, "../Windows/epanetmsx.dll") + libepanet = resource_filename(__name__, "../libepanet/windows-x64/epanet2.dll") + libmsx = resource_filename(__name__, "../libepanet/windows-x64/epanetmsx.dll") elif sys.platform in ["darwin"]: - libepanet = resource_filename(__name__, "../Darwin/libepanet2.dylib") - libmsx = resource_filename(__name__, "../Darwin/libepanetmsx.dylib") + if 'arm' in platform.platform().lower(): + libepanet = resource_filename(__name__, "../libepanet/darwin-arm/libepanet.dylib") + libmsx = resource_filename(__name__, "../libepanet/darwin-arm/libepanetmsx.dylib") + else: + libepanet = resource_filename(__name__, "../libepanet/darwin-x64/libepanet.dylib") + libmsx = resource_filename(__name__, "../libepanet/darwin-x64/libepanetmsx.dylib") else: - libepanet = resource_filename(__name__, "../Linux/libepanet2.so") - libmsx = resource_filename(__name__, "../Linux/libepanetmsx.so") + libepanet = resource_filename(__name__, "../libepanet/linux-x64/libepanet2.so") + libmsx = resource_filename(__name__, "../libepanet/linux-x64/epanetmsx.dll") dylib_dir = os.environ.get('DYLD_FALLBACK_LIBRARY_PATH','') if dylib_dir != '': - dylib_dir = dylib_dir + ':' + resource_filename(__name__, "../Darwin") + if 'arm' in platform.platform().lower(): + dylib_dir = dylib_dir + ':' + resource_filename(__name__, "../libepanet/darwin-arm") + else: + dylib_dir = dylib_dir + ':' + resource_filename(__name__, "../libepanet/darwin-x64") os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = dylib_dir -import logging - -logger = logging.getLogger(__name__) - class MSXepanet(ENepanet): def __init__(self, inpfile="", rptfile="", binfile="", msxfile=""): diff --git a/wntr/epanet/toolkit.py b/wntr/epanet/toolkit.py index 95cb56834..bcd892d1d 100644 --- a/wntr/epanet/toolkit.py +++ b/wntr/epanet/toolkit.py @@ -20,11 +20,14 @@ epanet_toolkit = "wntr.epanet.toolkit" if os.name in ["nt", "dos"]: - libepanet = resource_filename(__name__, "Windows/epanet2.dll") + libepanet = resource_filename(__name__, "libepanet/windows-x64/epanet2.dll") elif sys.platform in ["darwin"]: - libepanet = resource_filename(__name__, "Darwin/libepanet.dylib") + if 'arm' in platform.platform().lower(): + libepanet = resource_filename(__name__, "libepanet/darwin-arm/libepanet.dylib") + else: + libepanet = resource_filename(__name__, "libepanet/darwin-x64/libepanet.dylib") else: - libepanet = resource_filename(__name__, "Linux/libepanet2.so") + libepanet = resource_filename(__name__, "libepanet/linux-x64/libepanet2.so") def ENgetwarning(code, sec=-1):