MCPcopy Create free account
hub / github.com/MITK/MITK / ActivateVirtualEnv

Function ActivateVirtualEnv

Modules/Python/src/mitkPythonContext.cpp:27–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace
26{
27 void ActivateVirtualEnv(const std::string& venvName)
28 {
29 if (!mitk::PythonHelper::VirtualEnvExists(venvName))
30 {
31 MITK_INFO << "Create virtual environment: " << venvName;
32 const auto venvPath = mitk::PythonHelper::CreateVirtualEnv(venvName);
33
34 if (venvPath.empty())
35 mitkThrow() << "Could not create virtual environment: "
36 << mitk::PythonHelper::GetVirtualEnvPath(venvName);
37 }
38
39 if (!mitk::PythonHelper::ActivateVirtualEnv(venvName))
40 mitkThrow() << "Could not activate virtual environment: " << venvName;
41
42 MITK_INFO << "Using virtual environment: " << venvName;
43 }
44
45 // Inserts a key into a dict on construction and removes it on
46 // destruction. GIL must be held by the caller for both. Used to scope

Callers 4

PythonContextMethod · 0.85
ActivateVirtualEnvMethod · 0.85
OnProcessFinishedMethod · 0.85
BeginVirtualEnvPhaseMethod · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected