13 #ifndef QmitkSetupVirtualEnvUtil_h_Included
14 #define QmitkSetupVirtualEnvUtil_h_Included
29 using CallbackType = void (*)(itk::Object *,
const itk::EventObject &,
void *);
43 const QStringList &packages,
44 std::function<
bool()> validator,
46 const QString &torchVersion =
"");
67 const std::string &workingDir,
69 const std::string &command =
"pip3");
79 const std::string &command =
"pip3");
92 const std::string &pythonPath,
94 const std::string &command =
"python");
105 const std::string &command =
"python");
229 QString m_PythonPath;
233 QString m_SysPythonPath;
#define MITKSEGMENTATIONUI_EXPORT
Abstract Class to Setup a python virtual environment and pip install required packages....
void ExecutePython(const std::string &args, const std::string &pythonPath, CallbackType callback, const std::string &command="python")
Function to execute any python code given a python path. Any callback function can be passed to proce...
void ExecutePython(const std::string &args, CallbackType callback, const std::string &command="python")
Overloaded function to Execute Python code. Any callback function can be passed to process the output...
static std::pair< QString, QString > GetExactPythonPath(const QString &pyEnv)
Get the exact Python path and version for any OS from the virtual environment path.
void PipInstall(const std::string &library, CallbackType callback, const std::string &command="pip3")
Overloaded function to Pip install a library function.
void(*)(itk::Object *, const itk::EventObject &, void *) CallbackType
static QStringList AutoParsePythonPaths()
Searches and parses paths of python virtual environments from predefined lookout locations.
QmitkSetupVirtualEnvUtil()
static void PrintProcessEvent(itk::Object *, const itk::EventObject &e, void *)
Function can be used as callback to simply print out all the process execution output parsed out from...
void InstallPytorch(const QString &workingDir, CallbackType callback, const QString &torchVersion="")
Installs pytorch using light-the-torch package, correctly identifying cuda version....
void InstallPytorch(CallbackType callback, const QString &torchVersion="")
Overloaded function to install pytorch using light-the-torch package, correctly identifying cuda vers...
void SetPipPath(const QString &path)
Set the Pip Path object.
void SetSystemPythonPath(const QString &path)
Set the System Python Path object.
void InstallPytorch(const QString &torchVersion="")
Overloaded function to install pytorch using light-the-torch package, correctly identifying cuda vers...
QString & GetSystemPythonPath()
Get the System Python Path object.
static QString GetPipPackageVersion(const QString &pythonPath, const QString &packageName)
Returns version of the pip installed package.
void SetVirtualEnvPath(const QString &path)
Set the Virtual Env Path object.
void SetPythonPath(const QString &path)
Set the Python Path object.
QmitkSetupVirtualEnvUtil(const QString &baseDir)
virtual QString GetVirtualEnvPath()
Get the Virtual Env Path object. Override this method in the respective tool installer class.
QString & GetBaseDir()
Get the Base Dir object.
bool IsPythonPath(const QString &pythonPath)
Check if the path provide has python executable or not.
static bool IsVenvInstalled(const QString &pythonPath)
Checks if venv module is available for the python.
QString & GetPipPath()
Get the Pip Path object.
QString & GetPythonPath()
Get the Python Path object.
void PipInstall(const std::string &library, const std::string &workingDir, CallbackType callback, const std::string &command="pip3")
Function to Pip install a library package given the location of pip3 executable. Any callback functio...
bool SetupVirtualEnv(const QString &venvName, const QStringList &packages, std::function< bool()> validator, CallbackType printCallback, const QString &torchVersion="")
Sets up a python virtual environment in the DKFZ directory with given.