Skip to content
Permalink
Browse files

automatically add MACOS environment variables if folders/dirs present…

… in bundle
  • Loading branch information
PeterPetrik committed Jul 22, 2020
1 parent 518cc16 commit 7565a647e7beb999a718a818cb07222725039e9a
Showing with 20 additions and 0 deletions.
  1. +19 −0 src/app/main.cpp
  2. +1 −0 src/python/qgspythonutilsimpl.cpp
@@ -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
@@ -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" );

0 comments on commit 7565a64

Please sign in to comment.
You can’t perform that action at this time.