Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
automatically add MACOS environment variables if folders/dirs present…
… in bundle (#37918)
  • Loading branch information
PeterPetrik committed Aug 3, 2020
1 parent 4f34b8a commit 8ed274b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/main.cpp
Expand Up @@ -1219,6 +1219,25 @@ int main( int argc, char *argv[] )
}
}
}

// Point PROJ_LIB at any PROJ_LIB share directory embedded in the app bundle
if ( !getenv( "PROJ_LIB" ) )
{
QString appResources( QDir::cleanPath( QgsApplication::pkgDataPath() ) );
if ( QFile::exists( appResources.append( "/proj" ) ) )
{
setenv( "PROJ_LIB", appResources.append( "/proj" ).toUtf8().constData(), 1 );
}
}

// Point PYTHONHOME to embedded interpreter if present in the bundle
if ( !getenv( "PYTHONHOME" ) )
{
if ( QFile::exists( QCoreApplication::applicationDirPath().append( "/bin/python3" ) ) )
{
setenv( "PYTHONHOME", QCoreApplication::applicationDirPath().toUtf8().constData(), 1 );
}
}
#endif

// custom environment variables
Expand Down
1 change: 1 addition & 0 deletions src/python/qgspythonutilsimpl.cpp
Expand Up @@ -60,6 +60,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
// isolating/loading the initial environ without requiring a virt env, e.g. homebrew or MacPorts installs on Mac
runString( QStringLiteral( "pyqgstart = os.getenv('PYQGIS_STARTUP')\n" ) );
runString( QStringLiteral( "if pyqgstart is not None and os.path.exists(pyqgstart):\n with open(pyqgstart) as f:\n exec(f.read())\n" ) );
runString( QStringLiteral( "if pyqgstart is not None and os.path.exists(os.path.join('%1', pyqgstart)):\n with open(os.path.join('%1', pyqgstart)) as f:\n exec(f.read())\n" ).arg( pythonPath() ) );

#ifdef Q_OS_WIN
runString( "oldhome=None" );
Expand Down

0 comments on commit 8ed274b

Please sign in to comment.