Rework how Python processes are launched

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19465
This commit is contained in:
Jon Evans
2025-01-03 17:21:03 -05:00
parent 2e0f688b97
commit 1a1120435f
4 changed files with 52 additions and 13 deletions
+6 -9
View File
@@ -408,7 +408,7 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
[this]( int aRetVal, const wxString& aOutput, const wxString& aError )
{
wxLogTrace( traceApi,
wxString::Format( "Manager: venv (%d): %s", aRetVal, aOutput ) );
wxString::Format( "Manager: created venv (python returned %d)", aRetVal ) );
if( !aError.IsEmpty() )
wxLogTrace( traceApi, wxString::Format( "Manager: venv err: %s", aError ) );
@@ -455,8 +455,8 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
manager.Execute( cmd,
[this]( int aRetVal, const wxString& aOutput, const wxString& aError )
{
wxLogTrace( traceApi, wxString::Format( "Manager: upgrade pip (%d): %s",
aRetVal, aOutput ) );
wxLogTrace( traceApi, wxString::Format( "Manager: upgrade pip returned %d",
aRetVal ) );
if( !aError.IsEmpty() )
{
@@ -501,15 +501,15 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
PYTHON_MANAGER manager( *python );
wxExecuteEnv env;
if( pythonHome )
env.env[wxS( "VIRTUAL_ENV" )] = *pythonHome;
#ifdef _WIN32
wxString systemRoot;
wxGetEnv( wxS( "SYSTEMROOT" ), &systemRoot );
env.env[wxS( "SYSTEMROOT" )] = systemRoot;
#endif
if( pythonHome )
env.env[wxS( "VIRTUAL_ENV" )] = *pythonHome;
wxString cmd = wxString::Format(
wxS( "-m pip install --no-input --isolated --prefer-binary --require-virtualenv "
"--exists-action i -r \"%s\"" ),
@@ -520,9 +520,6 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
manager.Execute( cmd,
[this, job]( int aRetVal, const wxString& aOutput, const wxString& aError )
{
if( !aOutput.IsEmpty() )
wxLogTrace( traceApi, wxString::Format( "Manager: pip: %s", aOutput ) );
if( !aError.IsEmpty() )
wxLogTrace( traceApi, wxString::Format( "Manager: pip stderr: %s", aError ) );