KiCad PCB EDA Suite
Loading...
Searching...
No Matches
python_manager.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef KICAD_PYTHON_MANAGER_H
22#define KICAD_PYTHON_MANAGER_H
23
24#include <functional>
25#include <optional>
26
27#include <wx/wx.h>
28
29#include <kicommon.h>
30
31
33{
34public:
35 PYTHON_MANAGER( const wxString& aInterpreterPath );
36
45 long Execute( const std::vector<wxString>& aArgs,
46 const std::function<void(int, const wxString&, const wxString&)>& aCallback,
47 const wxExecuteEnv* aEnv = nullptr,
48 bool aSaveOutput = false );
49
50 long ExecuteSync( const std::vector<wxString>& aArgs,
51 wxString* aStdout = nullptr, wxString* aStderr = nullptr,
52 const wxExecuteEnv* aEnv = nullptr );
53
54 wxString GetInterpreterPath() const { return m_interpreterPath; }
55 void SetInterpreterPath( const wxString& aPath ) { m_interpreterPath = aPath; }
56
61 static wxString FindPythonInterpreter();
62
63 static std::optional<wxString> GetPythonEnvironment( const wxString& aNamespace );
64
66 static std::optional<wxString> GetVirtualPython( const wxString& aNamespace );
67
68private:
70};
71
72
73#endif //KICAD_PYTHON_MANAGER_H
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.
wxString GetInterpreterPath() const
long ExecuteSync(const std::vector< wxString > &aArgs, wxString *aStdout=nullptr, wxString *aStderr=nullptr, const wxExecuteEnv *aEnv=nullptr)
void SetInterpreterPath(const wxString &aPath)
wxString m_interpreterPath
PYTHON_MANAGER(const wxString &aInterpreterPath)
#define KICOMMON_API
Definition kicommon.h:27