@@ -93,28 +93,42 @@ warnings.formatwarning = _itk_format_warning
93
93
def _initialize():
94
94
import os
95
95
96
- def _normalized_path(relative_posix_path):
96
+ _this_file_dir: str = os.path.dirname(__file__)
97
+
98
+ def _normalized_path(relative_posix_path: str, message) -> str:
99
+ norm_path: str = "None"
97
100
if relative_posix_path != "None":
98
- file_dir = os.path.split(__file__)[0]
99
101
relative_path = relative_posix_path.replace("/", os.sep)
100
- return os.path.normpath(os.path.join(file_dir, relative_path))
101
-
102
- # swig_lib: location of the swig-generated shared libraries
103
- _swig_lib = _normalized_path("@CONFIG_PYTHON_SWIGLIB_DIR@")
104
-
105
- # swig_py: location of the xxxPython.py swig-generated python interfaces
106
- _swig_py = _normalized_path("@CONFIG_PYTHON_SWIGPY_DIR@")
107
-
108
- # config_py: location of xxxConfig.py CMake-generated library descriptions
109
- _config_py = _normalized_path("@CONFIG_PYTHON_CONFIGPY_DIR@")
102
+ norm_path = os.path.normpath(os.path.join(_this_file_dir, relative_path))
103
+ if not os.path.exists(norm_path):
104
+ print(f"WARNING: Internal configuration path is invalid: {norm_path}")
105
+ print(f"WARNING: Invalid: {message}")
106
+ return norm_path
107
+
108
+ _swig_lib: str = _normalized_path(
109
+ "@CONFIG_PYTHON_SWIGLIB_DIR@",
110
+ "swig_lib: location of the swig-generated shared libraries",
111
+ )
112
+ _swig_py: str = _normalized_path(
113
+ "@CONFIG_PYTHON_SWIGPY_DIR@",
114
+ "swig_py: location of the xxxPython.py swig-generated python interfaces",
115
+ )
116
+ _config_py: str = _normalized_path(
117
+ "@CONFIG_PYTHON_CONFIGPY_DIR@",
118
+ "config_py: location of xxxConfig.py CMake-generated library descriptions",
119
+ )
120
+
121
+ _config_py_root: str = os.path.dirname(_config_py)
110
122
111
123
# put the itkConfig.py path in the path list
112
- _path = [os.path.join(_config_py, "..") ]
124
+ _path = [_config_py_root ]
113
125
# also populate path with the WRAPITK_PYTHON_PATH var
114
126
if "WRAPITK_PYTHON_PATH" in os.environ:
115
127
_path.extend(os.environ["WRAPITK_PYTHON_PATH"].split(":"))
116
128
117
- _doxygen_root = _normalized_path("../Doc")
129
+ # NOT IMPLEMENTED:
130
+ # _doxygen_root = _normalized_path("../Doc", "doxygen_root: location of the doxygen xml files.")
131
+ _doxygen_root: str = "None"
118
132
119
133
return _swig_lib, _swig_py, _config_py, _doxygen_root, _path
120
134
0 commit comments