From 656d7c2092545b18d981acfac000c73fb2128e4a Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 21 Mar 2023 14:28:46 -0700 Subject: Fix _socket module not found issue Need python310._pth, specifically 'import site' line, for embedded python + pip to get along. --- GUI/GUI/GUI/Frame.cpp | 14 -------------- GUI/GUI/GUI/PythonWrapper.cpp | 31 ------------------------------- GUI/package.ps1 | 5 ++++- Scripts/requirements.txt | 4 +++- TaSTT-Whisper | 2 +- 5 files changed, 8 insertions(+), 48 deletions(-) diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index eef8251..deccb52 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -1654,20 +1654,6 @@ void Frame::OnSetupPython(wxCommandEvent& event) } } - { - Log(transcribe_out_, " DEBUG: check sys.path\n"); - auto out_cb = [&](const std::string& out, const std::string& err) { - Log(transcribe_out_, "{}", out); - Log(transcribe_out_, "{}", err); - }; - if (!PythonWrapper::InvokeWithArgs({ - "Resources/Scripts/tst.py", - }, std::move(out_cb))) { - Log(transcribe_out_, "Failed to check sys.path!\n"); - return false; - } - } - Log(transcribe_out_, " Installing dependencies\n"); auto out_cb = [&](const std::string& out, const std::string& err) { Log(transcribe_out_, "{}", out); diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index 54f6686..0337072 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -294,37 +294,6 @@ bool PythonWrapper::InvokeCommandWithArgs(const std::string& cmd, return false; } } - - // Set up PYTHONPATH - std::filesystem::path py_path = (std::filesystem::current_path() / - "Resources/Python").lexically_normal(); - std::filesystem::path py_lib = (std::filesystem::current_path() / - "Resources/Python/Lib").lexically_normal(); - std::filesystem::path py_site_pkgs = (std::filesystem::current_path() / - "Resources/Python/Lib/site-packages").lexically_normal(); - std::ostringstream pypath_oss; - pypath_oss << py_path.string(); - pypath_oss << ';' << py_lib.string(); - pypath_oss << ';' << py_site_pkgs.string(); - out_cb("PYTHONPATH=" + pypath_oss.str() + "\n", ""); - if (!SetEnvironmentVariableA("PYTHONPATH", pypath_oss.str().c_str())) { - std::ostringstream err_oss; - err_oss << "Error while executing python command \"" << cmd_oss.str() - << "\": Failed to add site-packages to PYTHONPATH: " - << GetWin32ErrMsg() << std::endl; - out_cb("", err_oss.str()); - return false; - } - // Set up PYTHONHOME - out_cb("PYTHONHOME=" + py_path.string() + "\n", ""); - if (!SetEnvironmentVariableA("PYTHONHOME", py_path.string().c_str())) { - std::ostringstream err_oss; - err_oss << "Error while executing python command \"" << cmd_oss.str() - << "\": Failed to set PYTHONHOME: " - << GetWin32ErrMsg() << std::endl; - out_cb("", err_oss.str()); - return false; - } } std::string cmd_str = cmd_oss.str(); diff --git a/GUI/package.ps1 b/GUI/package.ps1 index fa5e162..5f15259 100644 --- a/GUI/package.ps1 +++ b/GUI/package.ps1 @@ -6,6 +6,8 @@ param( echo "Skip zip: $skip_zip" echo "Release: $release" +$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' + $install_dir = "TaSTT" if (Test-Path $install_dir) { @@ -28,7 +30,8 @@ if (-Not (Test-Path $py_dir)) { mkdir Python Expand-Archive $PYTHON_FILE -DestinationPath Python - rm Python/python310._pth + echo "../Scripts" >> Python/python310._pth + echo "import site" >> Python/python310._pth } $pip_path = "$py_dir/get-pip.py" diff --git a/Scripts/requirements.txt b/Scripts/requirements.txt index 573f316..c218302 100644 --- a/Scripts/requirements.txt +++ b/Scripts/requirements.txt @@ -1,10 +1,12 @@ +editdistance future==0.18.2 openvr pillow pyaudio python-osc playsound==1.2.2 +pyyaml + --extra-index-url https://download.pytorch.org/whl/cu116 torch==1.13.1+cu116 git+https://github.com/openai/whisper.git -editdistance diff --git a/TaSTT-Whisper b/TaSTT-Whisper index 5e30b23..aaa0188 160000 --- a/TaSTT-Whisper +++ b/TaSTT-Whisper @@ -1 +1 @@ -Subproject commit 5e30b2366a4a320f59ed7e0bfcfe72f5f8c9d108 +Subproject commit aaa0188da81056748ef8ffcd5ad86d6f4bffa6bd -- cgit v1.2.3