From 83b5fb8b57e9043e44fc26715eab4d93051f5f70 Mon Sep 17 00:00:00 2001 From: hrpzcf Date: Wed, 5 Jan 2022 10:32:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E5=AF=B9=E8=A7=A3?= =?UTF-8?q?=E9=87=8A=E5=99=A8=E4=BD=8D=E7=BD=AE=E7=9A=84=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/libpyi.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/library/libpyi.py b/library/libpyi.py index 7b1f326..3b376a3 100644 --- a/library/libpyi.py +++ b/library/libpyi.py @@ -43,11 +43,6 @@ class PyiTool(QObject): if os.path.isdir(path): self._cwd = path - @staticmethod - def _check(py_path): - """检查给出的Python路径是否有效。""" - return os.path.isfile(os.path.join(py_path, "python.exe")) - @property def pyi_path(self): """返回给出的Python路径中的pyinstaller可执行文件路径。""" @@ -62,10 +57,8 @@ class PyiTool(QObject): return bool(self.pyi_path) def initialize(self, py_path, cwd): - if self._check(py_path): - self._py_path = py_path - else: - self._py_path = "" + # 信任传入的py_path + self._py_path = py_path self._cwd = cwd self._process = None self._commands = [self.pyi_path] -- Gitee From f45975c6c168b70d03ac7747162ca22e60114c25 Mon Sep 17 00:00:00 2001 From: hrpzcf Date: Wed, 5 Jan 2022 10:35:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E5=B0=86Python=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=BB=8E=E8=8E=B7=E5=8F=96Pyenv.path=E6=94=B9=E4=B8=BAPyenv.en?= =?UTF-8?q?v=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RunPyKit.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RunPyKit.py b/RunPyKit.py index f489477..01a634f 100644 --- a/RunPyKit.py +++ b/RunPyKit.py @@ -123,7 +123,7 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): self._setup_other_widgets() self.connect_signals_slots() self.env_list = get_pyenv_list(load_conf("pths")) - self.path_list = [env.path for env in self.env_list] + self.path_list = [env.env_path for env in self.env_list] self.cur_pkgs_info = {} self._reverseds = [True, True, True, True] self.selected_env_index = 0 @@ -329,7 +329,7 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): except Exception: continue self.env_list.append(env) - self.path_list.append(env.path) + self.path_list.append(env.env_path) path_list_lower = [p.lower() for p in self.path_list] thread_search_envs = NewTask(search_env) @@ -384,7 +384,7 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): try: env = PyEnv(_path) self.env_list.append(env) - self.path_list.append(env.path) + self.path_list.append(env.env_path) except Exception: return NewMessageBox( "警告", @@ -1102,7 +1102,7 @@ class PyinstallerToolWindow(Ui_pyinstaller_tool, QMainWindow): def get_missing_imps(): imp_missings = ImportInspector( - self.toolwin_env.path, project_root + self.toolwin_env.env_path, project_root ).missing_items() missings.append(tuple(imp_missings)) @@ -1245,7 +1245,7 @@ class PyinstallerToolWindow(Ui_pyinstaller_tool, QMainWindow): self.lb_py_info.setText(self.toolwin_env.py_info()) self.pyi_tool.initialize( self.toolwin_env.env_path, - self._stored_conf.get("program_entry", os.getcwd()), + self._stored_conf.get("project_root", os.getcwd()), ) self.set_pyi_info() @@ -1336,7 +1336,7 @@ class PyinstallerToolWindow(Ui_pyinstaller_tool, QMainWindow): if self.toolwin_env is None: self._stored_conf["env_path"] = "" else: - self._stored_conf["env_path"] = self.toolwin_env.path + self._stored_conf["env_path"] = self.toolwin_env.env_path self._stored_conf["log_level"] = self.cb_log_level.currentText() self._stored_conf["file_ver_info"] = self.file_ver_info_text() self._stored_conf["debug_options"] = self.change_debug_options("get") -- Gitee From efee507078adee6814e33b837232691a531cb544 Mon Sep 17 00:00:00 2001 From: hrpzcf Date: Wed, 5 Jan 2022 11:14:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8C=85=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E8=87=AA=E5=8A=A8=E6=90=9C=E7=B4=A2=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=90=8CPython=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RunPyKit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RunPyKit.py b/RunPyKit.py index 01a634f..3790397 100644 --- a/RunPyKit.py +++ b/RunPyKit.py @@ -322,6 +322,9 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): def auto_search_env(self): def search_env(): for _path in all_py_paths(): + p = os.path.dirname(_path) + if os.path.isfile(os.path.join(p, "pyvenv.cfg")): + _path = p if _path.lower() in path_list_lower: continue try: -- Gitee From 6cb57661545f845319f5374a9632c0b7f0732ed9 Mon Sep 17 00:00:00 2001 From: hrpzcf Date: Wed, 5 Jan 2022 11:39:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8C=85=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E6=89=8B=E5=8A=A8=E6=B7=BB=E5=8A=A0Python?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E8=B7=AF=E5=BE=84=E5=8F=AF=E8=83=BD=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=87=8D=E5=A4=8D=E7=8E=AF=E5=A2=83=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RunPyKit.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/RunPyKit.py b/RunPyKit.py index 3790397..044b691 100644 --- a/RunPyKit.py +++ b/RunPyKit.py @@ -319,12 +319,11 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): else: self.tw_installed_info.clearSelection() + def auto_search_env(self): def search_env(): for _path in all_py_paths(): - p = os.path.dirname(_path) - if os.path.isfile(os.path.join(p, "pyvenv.cfg")): - _path = p + _path = _check_venv(_path) if _path.lower() in path_list_lower: continue try: @@ -377,7 +376,7 @@ class PackageManagerWindow(Ui_package_manager, QMainWindow): "无效的Python目录路径!", QMessageBox.Warning, ).exec_() - _path = os.path.normpath(_path) + _path = _check_venv(os.path.normpath(os.path.abspath(_path))) if _path.lower() in [p.lower() for p in self.path_list]: return NewMessageBox( "警告", @@ -2111,6 +2110,14 @@ class NewInputDialog(QInputDialog): return self.textValue(), self._confirm +def _check_venv(_path): + """检查是否是venv创建的虚拟Python环境并返回相应路径""" + p = os.path.dirname(_path) + if os.path.isfile(os.path.join(p, "pyvenv.cfg")): + return p + return _path + + def main(): global win_ins_pkg global win_package_mgr -- Gitee