15 #ifndef vtkProcessModulePythonInitializePython_h 16 #define vtkProcessModulePythonInitializePython_h 18 #include "vtkPSystemTools.h" 19 #include "vtkPVConfig.h" 20 #include "vtkPythonInterpreter.h" 22 #include <vtksys/SystemTools.hxx> 26 #define VTK_PYTHON_MAXPATH PATH_MAX 27 #elif defined(MAXPATHLEN) 28 #define VTK_PYTHON_MAXPATH MAXPATHLEN 30 #define VTK_PYTHON_MAXPATH 16384 39 void vtkPythonAppInitPrependPythonPath(
const std::string& dir)
43 std::string collapsed_dir = vtkPSystemTools::CollapseFullPath(dir.c_str());
44 if (vtkPSystemTools::FileIsDirectory(collapsed_dir.c_str()))
46 vtkPythonInterpreter::PrependPythonPath(collapsed_dir.c_str());
51 #ifndef PARAVIEW_FREEZE_PYTHON 53 void vtkPythonAppInitPrependPathWindows(
const std::string& SELF_DIR);
54 #elif defined(__APPLE__) 55 void vtkPythonAppInitPrependPathOsX(
const std::string& SELF_DIR);
57 void vtkPythonAppInitPrependPathLinux(
const std::string& SELF_DIR);
59 #endif // ifndef PARAVIEW_FREEZE_PYTHON 62 void vtkPythonAppInitPrependPath(
const std::string& SELF_DIR)
66 #ifndef PARAVIEW_FREEZE_PYTHON 68 vtkPythonAppInitPrependPathWindows(SELF_DIR);
69 #elif defined(__APPLE__) 70 vtkPythonAppInitPrependPathOsX(SELF_DIR);
72 vtkPythonAppInitPrependPathLinux(SELF_DIR);
74 #endif // ifndef PARAVIEW_FREEZE_PYTHON 95 strcat(system_path, SELF_DIR.c_str());
96 if (
char* oldpath = getenv(
"PATH"))
98 strcat(system_path,
";");
99 strcat(system_path, oldpath);
102 #endif // if defined(_WIN32) 105 #ifndef PARAVIEW_FREEZE_PYTHON 130 void vtkPythonAppInitPrependPathWindows(
const std::string& SELF_DIR)
138 std::string build_dir_site_packages;
139 #if defined(CMAKE_INTDIR) 140 build_dir_site_packages = SELF_DIR +
"/../../lib/site-packages";
142 build_dir_site_packages = SELF_DIR +
"/../lib/site-packages";
144 bool is_build_dir = vtkPSystemTools::FileExists(build_dir_site_packages.c_str());
147 vtkPythonAppInitPrependPythonPath(SELF_DIR);
148 #if defined(CMAKE_INTDIR) 149 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/../../lib/" + std::string(CMAKE_INTDIR));
151 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/../lib");
153 vtkPythonAppInitPrependPythonPath(build_dir_site_packages);
157 vtkPythonAppInitPrependPythonPath(SELF_DIR);
158 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"Lib");
159 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"Lib/site-packages");
160 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/../lib/paraview-" PARAVIEW_VERSION);
161 vtkPythonAppInitPrependPythonPath(
162 SELF_DIR +
"/../lib/paraview-" PARAVIEW_VERSION
"/site-packages");
165 vtkPythonAppInitPrependPythonPath(
166 SELF_DIR +
"/../lib/paraview-" PARAVIEW_VERSION
"/site-packages/vtk");
169 #elif defined(__APPLE__) 201 void vtkPythonAppInitPrependPathOsX(
const std::string& SELF_DIR)
206 std::string contents_dir = vtkPSystemTools::CollapseFullPath((SELF_DIR +
"/..").c_str());
207 is_app = (vtksys::SystemTools::GetFilenameName(contents_dir) ==
"Contents");
210 std::string lib_dir =
211 (is_app ==
false) ? (SELF_DIR +
"/../lib") : (SELF_DIR +
"/../../../../lib");
212 lib_dir = vtkPSystemTools::CollapseFullPath(lib_dir.c_str());
214 std::string cmakeconfig = (is_app ==
false) ? (SELF_DIR +
"/../ParaViewConfig.cmake")
215 : (SELF_DIR +
"/../../../../ParaViewConfig.cmake");
216 cmakeconfig = vtkPSystemTools::CollapseFullPath(cmakeconfig.c_str());
218 bool is_build_dir = vtkPSystemTools::FileExists(cmakeconfig.c_str());
222 bool is_unix_style_install =
223 vtkPSystemTools::FileExists((lib_dir +
"/paraview-" PARAVIEW_VERSION).c_str());
226 if (is_unix_style_install)
228 lib_dir = lib_dir +
"/paraview-" PARAVIEW_VERSION;
229 vtkPythonAppInitPrependPythonPath(lib_dir);
230 vtkPythonAppInitPrependPythonPath(lib_dir +
"/site-packages");
234 vtkPythonAppInitPrependPythonPath(lib_dir +
"/site-packages/vtk");
238 vtkPythonAppInitPrependPythonPath(lib_dir);
239 vtkPythonAppInitPrependPythonPath(lib_dir +
"/site-packages");
246 std::string app_root = SELF_DIR +
"/../..";
247 app_root = vtkPSystemTools::CollapseFullPath(app_root.c_str());
248 vtkPythonAppInitPrependPythonPath(app_root +
"/Contents/Libraries");
249 vtkPythonAppInitPrependPythonPath(app_root +
"/Contents/Python");
253 vtkGenericWarningMacro(
"Non-app bundle in install directory not supported");
258 void vtkPythonAppInitPrependPathLinux(
const std::string& SELF_DIR);
285 void vtkPythonAppInitPrependPathLinux(
const std::string& SELF_DIR)
290 bool is_build_dir = vtkPSystemTools::FileExists((SELF_DIR +
"/../ParaViewConfig.cmake").c_str());
293 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/../lib");
294 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/../lib/site-packages");
300 bool using_shared_libs =
false;
301 #ifdef BUILD_SHARED_LIBS 302 using_shared_libs =
true;
304 if (using_shared_libs)
306 vtkPythonAppInitPrependPythonPath(SELF_DIR);
307 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/site-packages");
311 vtkPythonAppInitPrependPythonPath(SELF_DIR +
"/site-packages/vtk");
315 vtkPythonAppInitPrependPythonPath(
316 SELF_DIR +
"/../lib/paraview-" PARAVIEW_VERSION
"/site-packages");
317 vtkPythonAppInitPrependPythonPath(
318 SELF_DIR +
"/../lib/paraview-" PARAVIEW_VERSION
"/site-packages/vtk");
323 #endif // ifndef PARAVIEW_FREEZE_PYTHON #define VTK_PYTHON_MAXPATH