Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
QmitkSetupVirtualEnvUtil.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.s
10 
11 ============================================================================*/
12 
13 #ifndef QmitkSetupVirtualEnvUtil_h_Included
14 #define QmitkSetupVirtualEnvUtil_h_Included
15 
16 #include "mitkLogMacros.h"
17 #include "mitkProcessExecutor.h"
19 #include <QString>
20 #include <QDir>
21 #include <QApplication>
22 
28 {
29 public:
30  QmitkSetupVirtualEnvUtil(const QString& baseDir);
32 
37  virtual bool SetupVirtualEnv(const QString& venvName) = 0;
38 
45  virtual QString GetVirtualEnvPath();
46 
57  void PipInstall(const std::string &library,
58  const std::string &workingDir,
59  void (*callback)(itk::Object *, const itk::EventObject &, void *),
60  const std::string &command = "pip3");
61 
69  void PipInstall(const std::string &library,
70  void (*callback)(itk::Object *, const itk::EventObject &, void *),
71  const std::string &command = "pip3");
72 
73 
83  void ExecutePython(const std::string &args,
84  const std::string &pythonPath,
85  void (*callback)(itk::Object *, const itk::EventObject &, void *),
86  const std::string &command = "python");
87 
96  void ExecutePython(const std::string &args,
97  void (*callback)(itk::Object *, const itk::EventObject &, void *),
98  const std::string &command = "python");
99 
108  void InstallPytorch(const std::string &workingDir, void (*callback)(itk::Object *, const itk::EventObject &, void *));
109 
114  void InstallPytorch();
115 
121  QString& GetBaseDir();
122 
128  QString& GetSystemPythonPath();
129 
135  QString& GetPythonPath();
136 
142  QString& GetPipPath();
143 
149  void SetSystemPythonPath(const QString& path);
150 
156  void SetPythonPath(const QString& path);
157 
163  void SetPipPath(const QString& path);
164 
170  void SetVirtualEnvPath(const QString &path);
171 
179  bool IsPythonPath(const QString &pythonPath);
180 
186  static void PrintProcessEvent(itk::Object *, const itk::EventObject &e, void *);
187 
188 private:
189  QString m_PythonPath;
190  QString m_PipPath;
191  QString m_BaseDir;
192  QString m_venvPath;
193  QString m_SysPythonPath;
194 };
195 #endif
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
QmitkSetupVirtualEnvUtil
Abstract Class to Setup a python virtual environment and pip install required packages....
Definition: QmitkSetupVirtualEnvUtil.h:27
mitkProcessExecutor.h
mitkLogMacros.h
MitkSegmentationUIExports.h