![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <PythonConfig.h>
Public Types | |
| enum class | Type { Venv , Conda , System , Bundled } |
Public Member Functions | |
| PythonConfig ()=default | |
| Type | type () const |
| const QString & | pythonHome () const |
| void | preparePythonProcess (QProcess &pythonProcess) const |
| PythonConfigPaths | pythonCompatiblePaths () const |
| Version | getVersion () const |
| bool | validateAndDisplayErrors (QWidget *parent=nullptr) const |
| void | initDefault () |
| void | initBundled () |
| void | initFromLocation (const QString &prefix) |
| void | initCondaEnv (const QString &condaPrefix) |
| Initialize the paths to use the conda environment stored at condaPrefix. More... | |
| void | initVenv (const QString &venvPrefix) |
| Initialize the paths to use the python venv stored at venvPrefix. More... | |
| void | initFromPythonExecutable (const QString &pythonExecutable) |
Static Public Member Functions | |
| static bool | IsInsideEnvironment () |
| static PythonConfig | fromContainingEnvironment () |
This class infers the right python home and python path for the python environment to be used.
Its only used for Windows (on other platform it doesn't do much) as on Windows we can't rely on the system's python.
Definition at line 71 of file PythonConfig.h.
|
strong |
| Enumerator | |
|---|---|
| Venv | |
| Conda | |
| System | |
| Bundled | |
Definition at line 74 of file PythonConfig.h.
|
default |
|
static |
Definition at line 385 of file PythonConfig.cpp.
References Conda, initFromPythonExecutable(), PathToPythonExecutableInEnv(), and Venv.
Referenced by PythonPlugin::PythonPlugin().
| Version PythonConfig::getVersion | ( | ) | const |
Calls the python.exe of this environment / config to get its version.
Definition at line 341 of file PythonConfig.cpp.
References GetPythonExeVersion(), and preparePythonProcess().
Referenced by validateAndDisplayErrors().
| void PythonConfig::initBundled | ( | ) |
Initialize the paths to point to where the Python environment was bundled on installation
Definition at line 202 of file PythonConfig.cpp.
References initFromLocation().
Referenced by PythonRuntimeSettings::pythonEnvConfig(), and PythonPlugin::PythonPlugin().
| void PythonConfig::initCondaEnv | ( | const QString & | condaPrefix | ) |
Initialize the paths to use the conda environment stored at condaPrefix.
Definition at line 283 of file PythonConfig.cpp.
References Conda.
Referenced by initFromLocation().
| void PythonConfig::initDefault | ( | ) |
Initialize python home and python path corresponding to the environment to be used.
Does nothing, as we rely on the system's python to be properly installed
Definition at line 193 of file PythonConfig.cpp.
References Bundled, and System.
Referenced by PythonRuntimeSettings::pythonEnvConfig().
| void PythonConfig::initFromLocation | ( | const QString & | prefix | ) |
Initialize from the path to an environment. Will try to guess if the environment is a conda env or a python venv
Definition at line 212 of file PythonConfig.cpp.
References Bundled, Conda, initCondaEnv(), initFromPythonExecutable(), initVenv(), PathToPythonExecutableInEnv(), and Venv.
Referenced by initBundled(), and PythonRuntimeSettings::pythonEnvConfig().
| void PythonConfig::initFromPythonExecutable | ( | const QString & | pythonExecutable | ) |
Definition at line 410 of file PythonConfig.cpp.
References Bundled, qtCompatCodecForName(), result, and QtCompatTextCodec::toUnicode().
Referenced by fromContainingEnvironment(), and initFromLocation().
| void PythonConfig::initVenv | ( | const QString & | venvPrefix | ) |
Initialize the paths to use the python venv stored at venvPrefix.
Definition at line 294 of file PythonConfig.cpp.
References PyVenvCfg::FromFile(), PyVenvCfg::home, PyVenvCfg::includeSystemSitesPackages, and Venv.
Referenced by initFromLocation().
|
static |
Definition at line 380 of file PythonConfig.cpp.
Referenced by PythonPlugin::PythonPlugin().
| void PythonConfig::preparePythonProcess | ( | QProcess & | pythonProcess | ) | const |
Sets the necessary settings of the QProcess so that it uses the correct Python exe.
Definition at line 311 of file PythonConfig.cpp.
References Conda, cloudViewer::t::geometry::path, PathToPythonExecutableInEnv(), and type().
Referenced by getVersion(), and PackageManager::PackageManager().
| PythonConfigPaths PythonConfig::pythonCompatiblePaths | ( | ) | const |
Returns the python home & path stored in types that the CPython API can use.
Definition at line 333 of file PythonConfig.cpp.
References QStringToWcharArray().
|
inline |
Definition at line 109 of file PythonConfig.h.
Referenced by PackageManager::PackageManager().
|
inline |
Definition at line 84 of file PythonConfig.h.
Referenced by PackageManager::PackageManager(), preparePythonProcess(), and PythonPlugin::PythonPlugin().
| bool PythonConfig::validateAndDisplayErrors | ( | QWidget * | parent = nullptr | ) | const |
Does some basic validation (check is python executable exists and checks if its version is compatible) and displays a GUI with a message describing the error to the user.
| parent | parent for the GUI to be displayed, can be nullptr |
Definition at line 348 of file PythonConfig.cpp.
References getVersion(), Version::isCompatibleWithCompiledVersion(), Version::isNull(), PythonVersion(), Version::versionMajor, Version::versionMinor, and Version::versionPatch.
Referenced by PythonPlugin::PythonPlugin().