OrcFxAPI 11.4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
OrcFxAPIConfig.py ADDED
@@ -0,0 +1,69 @@
1
+ import sys
2
+
3
+ if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 6):
4
+ raise ImportError("OrcFxAPI requires Python 3.6 or later")
5
+ import os
6
+ import os.path
7
+ import ctypes
8
+ import ctypes.wintypes
9
+ import builtins
10
+ import winreg
11
+ from typing import Optional, Union
12
+
13
+ _libPathName = "_OrcFxAPIlib"
14
+ _libHandleName = "_OrcFxAPIlibHandle"
15
+ _libPath = None
16
+ _libHandle = None
17
+
18
+
19
+ def getLibPath() -> str:
20
+ result = _libPath
21
+ if result is not None:
22
+ return result
23
+
24
+ result = os.environ.get(_libPathName, None)
25
+ if result is not None:
26
+ return result
27
+
28
+ try:
29
+ with winreg.OpenKey(
30
+ winreg.HKEY_LOCAL_MACHINE,
31
+ "Software\\Orcina\\OrcaFlex\\Installation Directory",
32
+ 0,
33
+ winreg.KEY_READ | winreg.KEY_WOW64_32KEY,
34
+ ) as key:
35
+ installationDirectory = winreg.QueryValueEx(key, "Normal")[0]
36
+ except BaseException: # registry key will not exist if OrcaFlex is not installed
37
+ raise Exception("OrcaFlex not found")
38
+ is64bit = ctypes.sizeof(ctypes.c_void_p) == 8
39
+ if is64bit:
40
+ platform = "Win64"
41
+ else:
42
+ platform = "Win32"
43
+ return os.path.join(installationDirectory, "OrcFxAPI", platform, "OrcFxAPI.dll")
44
+
45
+
46
+ def setLibPath(value: Union[str, os.PathLike], childProcessInherit: Optional[bool] = False) -> None:
47
+ global _libPath
48
+ _libPath = os.path.abspath(str(value))
49
+ if childProcessInherit:
50
+ os.environ[_libPathName] = _libPath
51
+
52
+
53
+ def getLibHandle() -> Optional[ctypes.wintypes.HMODULE]:
54
+ result = _libHandle
55
+ if result is None:
56
+ result = getattr(builtins, _libHandleName, None)
57
+ return result
58
+
59
+
60
+ def setLibHandle(value: ctypes.wintypes.HMODULE) -> None:
61
+ global _libHandle
62
+ _libHandle = value
63
+
64
+
65
+ def lib() -> ctypes.WinDLL:
66
+ libHandle = getLibHandle()
67
+ if libHandle:
68
+ return ctypes.WinDLL("", handle=libHandle) # type: ignore[arg-type]
69
+ return ctypes.WinDLL(getLibPath())