Medical Imaging Interaction Toolkit  2023.12.99-f298153c
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 "mitkLog.h"
17 #include "mitkProcessExecutor.h"
19 #include <QString>
20 
26 {
27 public:
28  QmitkSetupVirtualEnvUtil(const QString& baseDir);
30 
35  virtual bool SetupVirtualEnv(const QString& venvName) = 0;
36 
43  virtual QString GetVirtualEnvPath();
44 
55  void PipInstall(const std::string &library,
56  const std::string &workingDir,
57  void (*callback)(itk::Object *, const itk::EventObject &, void *),
58  const std::string &command = "pip3");
59 
67  void PipInstall(const std::string &library,
68  void (*callback)(itk::Object *, const itk::EventObject &, void *),
69  const std::string &command = "pip3");
70 
71 
81  void ExecutePython(const std::string &args,
82  const std::string &pythonPath,
83  void (*callback)(itk::Object *, const itk::EventObject &, void *),
84  const std::string &command = "python");
85 
94  void ExecutePython(const std::string &args,
95  void (*callback)(itk::Object *, const itk::EventObject &, void *),
96  const std::string &command = "python");
97 
106  void InstallPytorch(const std::string &workingDir, void (*callback)(itk::Object *, const itk::EventObject &, void *));
107 
112  void InstallPytorch();
113 
119  QString& GetBaseDir();
120 
126  QString& GetSystemPythonPath();
127 
133  QString& GetPythonPath();
134 
140  QString& GetPipPath();
141 
147  void SetSystemPythonPath(const QString& path);
148 
154  void SetPythonPath(const QString& path);
155 
161  void SetPipPath(const QString& path);
162 
168  void SetVirtualEnvPath(const QString &path);
169 
177  bool IsPythonPath(const QString &pythonPath);
178 
184  static void PrintProcessEvent(itk::Object *, const itk::EventObject &e, void *);
185 
191  static std::pair<QString, QString> GetExactPythonPath(const QString &pyEnv);
192 
193 private:
194  QString m_PythonPath;
195  QString m_PipPath;
196  QString m_BaseDir;
197  QString m_venvPath;
198  QString m_SysPythonPath;
199 };
200 #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:25
mitkProcessExecutor.h
mitkLog.h
MitkSegmentationUIExports.h