Skip to content

Commit

Permalink
python: also add site-packages to PYTHONPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Nov 1, 2021
1 parent cafda94 commit 075ea8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Engine/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,7 @@ AppManager::initPython()
QString pyPathZip = QString::fromUtf8( (pythonHome + "/lib/python" NATRON_PY_VERSION_STRING_NO_DOT ".zip").c_str() );
QString pyPath = QString::fromUtf8( (pythonHome + "/lib/python" NATRON_PY_VERSION_STRING).c_str() );
QString pyPathDynLoad = pyPath + QString::fromUtf8("/lib-dynload");
QString pyPathSitePackages = pyPath + QString::fromUtf8("/site-packages");
QString pluginPath = binPath + QString::fromUtf8("/../Plugins");
#endif
if ( !QFile( QDir::fromNativeSeparators(pyPathZip) ).exists() ) {
Expand All @@ -3015,6 +3016,12 @@ AppManager::initPython()
# endif
pyPathDynLoad.clear();
}
if ( !QDir( QDir::fromNativeSeparators(pyPathSitePackages) ).exists() ) {
# if defined(NATRON_CONFIG_SNAPSHOT) || defined(DEBUG)
printf( "\"%s\" does not exist, not added to PYTHONPATH\n", pyPathSitePackages.toStdString().c_str() );
# endif
pyPathSitePackages.clear();
}
if ( !QDir( QDir::fromNativeSeparators(pluginPath) ).exists() ) {
# if defined(NATRON_CONFIG_SNAPSHOT) || defined(DEBUG)
printf( "\"%s\" does not exist, not added to PYTHONPATH\n", pluginPath.toStdString().c_str() );
Expand Down Expand Up @@ -3075,6 +3082,9 @@ AppManager::initPython()
if ( !pyPathDynLoad.isEmpty() ) {
toPrepend.append(pyPathDynLoad);
}
if ( !pyPathSitePackages.isEmpty() ) {
toPrepend.append(pyPathSitePackages);
}
if ( !pluginPath.isEmpty() ) {
toPrepend.append(pluginPath);
}
Expand Down
10 changes: 10 additions & 0 deletions Global/PythonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void setupPythonEnv(const char* argv0Param)
std::string pyPathZip = pythonHome + "/lib/python" NATRON_PY_VERSION_STRING_NO_DOT ".zip";
std::string pyPath = pythonHome + "/lib/python" NATRON_PY_VERSION_STRING;
std::string pyPathDynLoad = pyPath + "/lib-dynload";
std::string pyPathSitePackages = pyPath + "/site-packages";
std::string pluginPath = binPath + "/../Plugins";
#endif
if ( !fileExists( StrUtils::fromNativeSeparators(pyPathZip) ) ) {
Expand All @@ -122,6 +123,12 @@ void setupPythonEnv(const char* argv0Param)
# endif
pyPathDynLoad.clear();
}
if ( !dirExists( StrUtils::fromNativeSeparators(pyPathSitePackages) ) ) {
# if defined(NATRON_CONFIG_SNAPSHOT) || defined(DEBUG)
printf( "\"%s\" does not exist, not added to PYTHONPATH\n", pyPathSitePackages.c_str() );
# endif
pyPathSitePackages.clear();
}
if ( !dirExists( StrUtils::fromNativeSeparators(pluginPath) ) ) {
# if defined(NATRON_CONFIG_SNAPSHOT) || defined(DEBUG)
printf( "\"%s\" does not exist, not added to PYTHONPATH\n", pluginPath.c_str() );
Expand Down Expand Up @@ -184,6 +191,9 @@ void setupPythonEnv(const char* argv0Param)
if ( !pyPathDynLoad.empty() ) {
toPrepend.push_back(pyPathDynLoad);
}
if ( !pyPathSitePackages.empty() ) {
toPrepend.push_back(pyPathSitePackages);
}
if ( !pluginPath.empty() ) {
toPrepend.push_back(pluginPath);
}
Expand Down

0 comments on commit 075ea8e

Please sign in to comment.