Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
183  static bool IsVenvInstalled(const QString &pythonPath);
184 
189  static QString GetPipPackageVersion(const QString &pythonPath, const QString &packageName);
190 
196  static void PrintProcessEvent(itk::Object *, const itk::EventObject &e, void *);
197 
203  static std::pair<QString, QString> GetExactPythonPath(const QString &pyEnv);
204 
205 private:
206  QString m_PythonPath;
207  QString m_PipPath;
208  QString m_BaseDir;
209  QString m_venvPath;
210  QString m_SysPythonPath;
211 };
212 #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