7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-07 18:35:32 +00:00

Fix some issues calling Python on Windows systems

This commit is contained in:
Jon Evans 2025-01-02 22:45:05 -05:00
parent e13b31fd42
commit 89a50a3dcf
2 changed files with 20 additions and 2 deletions

View File

@ -403,7 +403,7 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
PYTHON_MANAGER manager( Pgm().GetCommonSettings()->m_Api.python_interpreter );
manager.Execute(
wxString::Format( wxS( "-m venv --system-site-packages '%s'" ),
wxString::Format( wxS( "-m venv --system-site-packages \"%s\"" ),
job.env_path ),
[this]( int aRetVal, const wxString& aOutput, const wxString& aError )
{
@ -443,6 +443,12 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
if( pythonHome )
env.env[wxS( "VIRTUAL_ENV" )] = *pythonHome;
#ifdef _WIN32
wxString systemRoot;
wxGetEnv( wxS( "SYSTEMROOT" ), &systemRoot );
env.env[wxS( "SYSTEMROOT" )] = systemRoot;
#endif
wxString cmd = wxS( "-m pip install --upgrade pip" );
wxLogTrace( traceApi, "Manager: calling python %s", cmd );
@ -498,9 +504,15 @@ void API_PLUGIN_MANAGER::processNextJob( wxCommandEvent& aEvent )
if( pythonHome )
env.env[wxS( "VIRTUAL_ENV" )] = *pythonHome;
#ifdef _WIN32
wxString systemRoot;
wxGetEnv( wxS( "SYSTEMROOT" ), &systemRoot );
env.env[wxS( "SYSTEMROOT" )] = systemRoot;
#endif
wxString cmd = wxString::Format(
wxS( "-m pip install --no-input --isolated --prefer-binary --require-virtualenv "
"--exists-action i -r '%s'" ),
"--exists-action i -r \"%s\"" ),
reqs.GetFullPath() );
wxLogTrace( traceApi, "Manager: calling python %s", cmd );

View File

@ -181,8 +181,14 @@ std::optional<wxString> PYTHON_MANAGER::GetVirtualPython( const wxString& aNames
return std::nullopt;
wxFileName python( *envPath, wxEmptyString );
#ifdef _WIN32
python.AppendDir( "Scripts" );
python.SetFullName( "python.exe" );
#else
python.AppendDir( "bin" );
python.SetFullName( "python" );
#endif
if( !python.IsFileExecutable() )
return std::nullopt;