forked from tpaviot/pythonocc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
51 lines (41 loc) · 1.61 KB
/
__init__.py
File metadata and controls
51 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from pathlib import Path
import platform
# Version number
PYTHONOCC_VERSION_MAJOR = 7
PYTHONOCC_VERSION_MINOR = 9
PYTHONOCC_VERSION_PATCH = 0
# Empty for official releases, set to -dev, -rc1, etc for development releases
PYTHONOCC_VERSION_DEVEL = ""
VERSION = f"{PYTHONOCC_VERSION_MAJOR}.{PYTHONOCC_VERSION_MINOR}.{PYTHONOCC_VERSION_PATCH}{PYTHONOCC_VERSION_DEVEL}"
def initialize_occt_libraries(occt_essentials_path) -> None:
"""
Initializes the OCCT libraries by adding all DLL directories to the DLL search path.
Raises:
AssertionError: If the OCCT_ESSENTIALS_ROOT environment variable is not set.
"""
if not os.path.exists(occt_essentials_path):
raise AssertionError(
f"OCCT_ESSENTIALS_ROOT({occt_essentials_path}) is not set correctly."
)
for root, dirs, files in os.walk(occt_essentials_path):
if "debug" in root.lower():
continue
for file in files:
if Path(file).suffix.lower() == ".dll":
os.add_dll_directory(root)
break
# on windows, see #1347
if platform.system() == "Windows":
try:
# OCC_ESSENTIALS_ROOT was defined at build time
# and is available in config.py
from .config import OCCT_ESSENTIALS_ROOT
initialize_occt_libraries(occt_essentials_path=OCCT_ESSENTIALS_ROOT)
except (
ImportError
): # anyway, still possible to set up the OCC_ESSENTIALS_ROOT env var
if "OCCT_ESSENTIALS_ROOT" in os.environ:
initialize_occt_libraries(
occt_essentials_path=os.environ["OCCT_ESSENTIALS_ROOT"]
)