Skip to content

Commit

Permalink
Added python virtual environment initialization, if present.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzieyguywuf authored and wwmayer committed May 22, 2019
1 parent 1eca20d commit 81bae31
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Base/Interpreter.cpp
Expand Up @@ -494,6 +494,18 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
// https://bugs.python.org/issue17797#msg197474
//
Py_Initialize();
const char* virtualenv = getenv("VIRTUAL_ENV");
if (virtualenv) {
PyRun_SimpleString(R"***(
# Check for virtualenv, and activate if present. See https://virtualenv.pypa.io/en/latest/userguide/#using-virtualenv-without-bin-python
import os
import sys
base_path = os.getenv("VIRTUAL_ENV")
if not base_path is None:
activate_this = os.path.join(base_path, "bin", "activate_this.py")
exec(open(activate_this).read(), {'__file__':activate_this})
)***");
}
PyEval_InitThreads();
#if PY_MAJOR_VERSION >= 3
size_t size = argc;
Expand Down

0 comments on commit 81bae31

Please sign in to comment.