mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
get python3 scripts running with venv
This commit is contained in:
+10
-2
@@ -469,8 +469,16 @@ static int CmdScriptRun(const char *Cmd) {
|
||||
|
||||
// We disallowed in py_conf environment variables interfering with python interpreter's behavior.
|
||||
// Let's manually enable the ones we truly need.
|
||||
// This is required by Proxspace to work with an isolated Python configuration
|
||||
PyConfig_SetBytesString(&py_conf, &py_conf.home, getenv("PYTHONHOME"));
|
||||
const char *virtual_env = getenv("VIRTUAL_ENV");
|
||||
if (virtual_env != NULL) {
|
||||
size_t length = strlen(virtual_env) + strlen("/bin/python3") + 1;
|
||||
char python_executable_path[length];
|
||||
snprintf(python_executable_path, length, "%s/bin/python3", virtual_env);
|
||||
PyConfig_SetBytesString(&py_conf, &py_conf.executable, python_executable_path);
|
||||
} else {
|
||||
// This is required by Proxspace to work with an isolated Python configuration
|
||||
PyConfig_SetBytesString(&py_conf, &py_conf.home, getenv("PYTHONHOME"));
|
||||
}
|
||||
// This is required for allowing `import pm3` in python scripts
|
||||
PyConfig_SetBytesString(&py_conf, &py_conf.pythonpath_env, getenv("PYTHONPATH"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user