KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PYTHON_MANAGER Class Reference

#include <python_manager.h>

Public Member Functions

 PYTHON_MANAGER (const wxString &aInterpreterPath)
 
long Execute (const std::vector< wxString > &aArgs, const std::function< void(int, const wxString &, const wxString &)> &aCallback, const wxExecuteEnv *aEnv=nullptr, bool aSaveOutput=false)
 Launches the Python interpreter with the given arguments.
 
long ExecuteSync (const std::vector< wxString > &aArgs, wxString *aStdout=nullptr, wxString *aStderr=nullptr, const wxExecuteEnv *aEnv=nullptr)
 
wxString GetInterpreterPath () const
 
void SetInterpreterPath (const wxString &aPath)
 

Static Public Member Functions

static wxString FindPythonInterpreter ()
 Searches for a Python intepreter on the user's system.
 
static std::optional< wxString > GetPythonEnvironment (const wxString &aNamespace)
 
static std::optional< wxString > GetVirtualPython (const wxString &aNamespace)
 Returns a full path to the python binary in a venv, if it exists.
 

Private Attributes

wxString m_interpreterPath
 

Detailed Description

Definition at line 32 of file python_manager.h.

Constructor & Destructor Documentation

◆ PYTHON_MANAGER()

PYTHON_MANAGER::PYTHON_MANAGER ( const wxString & aInterpreterPath)

Definition at line 85 of file python_manager.cpp.

References FN_NORMALIZE_FLAGS, m_interpreterPath, and path.

Member Function Documentation

◆ Execute()

long PYTHON_MANAGER::Execute ( const std::vector< wxString > & aArgs,
const std::function< void(int, const wxString &, const wxString &)> & aCallback,
const wxExecuteEnv * aEnv = nullptr,
bool aSaveOutput = false )

Launches the Python interpreter with the given arguments.

Parameters
aArgs
aCallback
aEnv
aSaveOutput
Returns
the process ID of the created process, or 0 if one was not created

Definition at line 93 of file python_manager.cpp.

References _, GetKiCadThreadPool(), m_interpreterPath, process, tp, and traceApi.

Referenced by API_PLUGIN_MANAGER::doInvokeAction(), API_PLUGIN_MANAGER::processNextJob(), and PANEL_PLUGIN_SETTINGS::validatePythonInterpreter().

◆ ExecuteSync()

long PYTHON_MANAGER::ExecuteSync ( const std::vector< wxString > & aArgs,
wxString * aStdout = nullptr,
wxString * aStderr = nullptr,
const wxExecuteEnv * aEnv = nullptr )

Definition at line 183 of file python_manager.cpp.

References m_interpreterPath, and traceApi.

Referenced by API_PLUGIN_MANAGER::doInvokeAction().

◆ FindPythonInterpreter()

wxString PYTHON_MANAGER::FindPythonInterpreter ( )
static

Searches for a Python intepreter on the user's system.

Returns
the absolute path to a Python interpreter, or an empty string if one was not found

Definition at line 215 of file python_manager.cpp.

References FindKicadFile(), and output.

Referenced by PGM_BASE::InitPgm(), and PANEL_PLUGIN_SETTINGS::OnBtnDetectAutomaticallyClicked().

◆ GetInterpreterPath()

wxString PYTHON_MANAGER::GetInterpreterPath ( ) const
inline

Definition at line 54 of file python_manager.h.

References m_interpreterPath.

◆ GetPythonEnvironment()

std::optional< wxString > PYTHON_MANAGER::GetPythonEnvironment ( const wxString & aNamespace)
static

◆ GetVirtualPython()

std::optional< wxString > PYTHON_MANAGER::GetVirtualPython ( const wxString & aNamespace)
static

Returns a full path to the python binary in a venv, if it exists.

Definition at line 276 of file python_manager.cpp.

References GetPythonEnvironment().

Referenced by API_PLUGIN_MANAGER::doInvokeAction(), and API_PLUGIN_MANAGER::processNextJob().

◆ SetInterpreterPath()

void PYTHON_MANAGER::SetInterpreterPath ( const wxString & aPath)
inline

Definition at line 55 of file python_manager.h.

References m_interpreterPath.

Member Data Documentation

◆ m_interpreterPath

wxString PYTHON_MANAGER::m_interpreterPath
private

The documentation for this class was generated from the following files: