|
KiCad PCB EDA Suite
|
#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. | |
| static std::optional< wxString > | GetVenvInterpreter (const wxString &aEnvPath) |
| Returns the path of the interpreter that was used to create the venv in the given environment directory according to its config file. | |
| static bool | IsVenvUsable (const wxString &aEnvPath) |
| static bool | IsVenvStale (const wxString &aEnvPath, const wxString &aConfiguredInterpreter) |
| Returns true if the venv at aEnvPath was created by an interpreter other than aConfiguredInterpreter. | |
Private Attributes | |
| wxString | m_interpreterPath |
Definition at line 32 of file python_manager.h.
| PYTHON_MANAGER::PYTHON_MANAGER | ( | const wxString & | aInterpreterPath | ) |
Definition at line 86 of file python_manager.cpp.
References FN_NORMALIZE_FLAGS, m_interpreterPath, and path.
| 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.
| aArgs | |
| aCallback | |
| aEnv | |
| aSaveOutput |
Definition at line 113 of file python_manager.cpp.
References _, GetKiCadThreadPool(), m_interpreterPath, process, readAllFromStream(), tp, and traceApi.
Referenced by API_PLUGIN_MANAGER::doInvokeAction(), API_PLUGIN_MANAGER::processNextJob(), and PANEL_PLUGIN_SETTINGS::validatePythonInterpreter().
| long PYTHON_MANAGER::ExecuteSync | ( | const std::vector< wxString > & | aArgs, |
| wxString * | aStdout = nullptr, | ||
| wxString * | aStderr = nullptr, | ||
| const wxExecuteEnv * | aEnv = nullptr ) |
Definition at line 212 of file python_manager.cpp.
References m_interpreterPath, process, readAllFromStream(), and traceApi.
Referenced by API_PLUGIN_MANAGER::doInvokeAction().
|
static |
Searches for a Python intepreter on the user's system.
Definition at line 252 of file python_manager.cpp.
References FindKicadFile().
Referenced by PGM_BASE::InitPgm(), and PANEL_PLUGIN_SETTINGS::OnBtnDetectAutomaticallyClicked().
|
inline |
Definition at line 54 of file python_manager.h.
References m_interpreterPath.
|
static |
Definition at line 300 of file python_manager.cpp.
References PATHS::EnsurePathExists(), PATHS::GetUserCachePath(), and path.
Referenced by API_PLUGIN_MANAGER::doInvokeAction(), GetVirtualPython(), API_PLUGIN_MANAGER::HandlePythonInterpreterChanged(), API_PLUGIN_MANAGER::processNextJob(), API_PLUGIN_MANAGER::processPluginDependencies(), and API_PLUGIN_MANAGER::RecreatePluginEnvironment().
|
static |
Returns the path of the interpreter that was used to create the venv in the given environment directory according to its config file.
May return nullopt if the venv is invalid but also if it was created with an older Python version (venv only started recording the executable path in Python 3.11)
Definition at line 353 of file python_manager.cpp.
Referenced by IsVenvStale(), and IsVenvUsable().
|
static |
Returns a full path to the python binary in a venv, if it exists.
Definition at line 313 of file python_manager.cpp.
References GetPythonEnvironment().
Referenced by API_PLUGIN_MANAGER::doInvokeAction(), and API_PLUGIN_MANAGER::processNextJob().
|
static |
Returns true if the venv at aEnvPath was created by an interpreter other than aConfiguredInterpreter.
Definition at line 415 of file python_manager.cpp.
References canonicalizePath(), and GetVenvInterpreter().
Referenced by API_PLUGIN_MANAGER::HandlePythonInterpreterChanged(), and API_PLUGIN_MANAGER::processPluginDependencies().
|
static |
Definition at line 385 of file python_manager.cpp.
References GetVenvInterpreter(), and venvPythonPath().
Referenced by API_PLUGIN_MANAGER::processPluginDependencies().
|
inline |
Definition at line 55 of file python_manager.h.
References m_interpreterPath.
|
private |
Definition at line 85 of file python_manager.h.
Referenced by Execute(), ExecuteSync(), GetInterpreterPath(), PYTHON_MANAGER(), and SetInterpreterPath().