Adjust macOS BOM plugin Python path

This commit is contained in:
Adam Wolf 2021-12-10 14:36:01 -06:00 committed by Seth Hillbrand
parent 5e2ca2aa2a
commit 4fd5c9cfa8
1 changed files with 24 additions and 2 deletions

View File

@ -73,10 +73,32 @@ BOM_GENERATOR_HANDLER::BOM_GENERATOR_HANDLER( const wxString& aFile )
m_file.GetFullName(),
getOutputExtension( m_info ) );
#else
wxString interpreter = wxString::FromUTF8Unchecked( PYTHON_EXECUTABLE );
// For macOS, we want to use the Python we bundle along, rather than just PYTHON_EXECUTABLE.
// For non-Windows, non-macOS, we can call out to PYTHON_EXECUTABLE.
#ifdef __APPLE__
// python is at Contents/Frameworks/Python.framework/Versions/Current/bin/python3
// Of course, for macOS, it's not quite that simple, since the relative path
// will depend on if we are in standalone mode or not.
// (If we're going to call out to python like this in other places, we probably want to
// think about pulling this into PATHS.)
wxFileName python( PATHS::GetOSXKicadDataDir(), wxEmptyString );
python.RemoveLastDir();
python.AppendDir( wxT( "Frameworks" ) );
python.AppendDir( wxT( "Python.framework" ) );
python.AppendDir( wxT( "Versions" ) );
python.AppendDir( wxT( "Current" ) );
python.AppendDir( wxT( "bin" ) );
python.SetFullName(wxT( "python3" ) );
wxString interpreter = python.GetFullPath();
#else
wxString interpreter = wxString::FromUTF8Unchecked( PYTHON_EXECUTABLE );
#endif
if( interpreter.IsEmpty() )
interpreter = wxT( "python" );
interpreter = wxT( "python" ); // For macOS, should we log here? Error here?
m_cmd = wxString::Format( "%s \"%s\" \"%%I\" \"%%O%s\"",
interpreter,