diff options
| author | yum <yum.food.vr@gmail.com> | 2023-03-06 02:48:00 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-03-06 02:48:00 -0800 |
| commit | 5d39ab1d6091241fb228a379da64a84436138f59 (patch) | |
| tree | 591aa5cb952a01f908dc7926a7e774e1a1e66946 | |
| parent | 058cd57ed2d18d6e14408881c3229fab7edbadb1 (diff) | |
Silence virtual env setup PATH warnings
Twofold approach:
* All spawned processes have the desired path (new codepath)
* Setup command silences the warning (old codepath)
| -rw-r--r-- | GUI/GUI/GUI/Frame.cpp | 1 | ||||
| -rw-r--r-- | GUI/GUI/GUI/PythonWrapper.cpp | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index f32f658..47fe624 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -1498,6 +1498,7 @@ void Frame::OnSetupPython(wxCommandEvent& event) "-m pip",
"install",
"-r Resources/Scripts/requirements.txt",
+ "--no-warn-script-location",
}, std::move(cb));
if (!p) {
Log(transcribe_out_, "Failed to launch environment setup thread!\n");
diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index c4b2b55..148692a 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -274,6 +274,20 @@ bool PythonWrapper::InvokeCommandWithArgs(const std::string& cmd, return false; } } + std::filesystem::path py_bin = (std::filesystem::current_path() / + "Resources\Python\Scripts").lexically_normal(); + if (env.find(py_bin.string()) == std::string::npos) { + env += ";" + py_bin.string(); + + // Add updated PATH to current process's environment + if (!SetEnvironmentVariableA("PATH", env.c_str())) { + std::ostringstream err_oss; + err_oss << "Error while executing python command \"" << cmd_oss.str() + << "\": Failed to add git to PATH: " << GetWin32ErrMsg() << std::endl; + out_cb("", err_oss.str()); + return false; + } + } } std::string cmd_str = cmd_oss.str(); |
