/
__init__.py.template
30 lines (23 loc) · 1.1 KB
/
__init__.py.template
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
try:
import FreeCAD as app
except ModuleNotFoundError:
# sys.path modification has not happened yet
import sys as _sys
import os as _os
# 1. we check if an env-variable "PATH_TO_FREECAD_LIB" is already set
try:
_path_to_freecad_libdir = _os.environ["PATH_TO_FREECAD_LIBDIR"]
except KeyError:
# 2. we use the default freecad defined for this package
_path_to_freecad_libdir = "${FREECAD_LIBRARY_INSTALL_DIR}"
print("PATH_TO_FREECAD_LIBDIR not specified, using default \
FreeCAD version in {}".format("${FREECAD_LIBRARY_INSTALL_DIR}"))
_sys.path.append(_path_to_freecad_libdir) # this is the default version
import FreeCAD as app
# as this is a namespace-package we need to extend the path
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TO NOT OVERWRITE THIS FILE, NO OTHER MODULE IS ALLOWED TO !
# PROVIDE A freecad/__init__.py FILE !
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
from pkgutil import extend_path as _extend_path
__path__ = _extend_path(__path__, __name__)