From 86e0f30e5874587429dff5adc9eda825ff241c4c Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 6 Jul 2026 16:33:07 +0800 Subject: [PATCH] fix: use site to get site-packages --- deploy/Windows/config.py | 11 +++++++---- deploy/Windows/pip.py | 14 ++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/deploy/Windows/config.py b/deploy/Windows/config.py index 25ca7cd..64edf7e 100644 --- a/deploy/Windows/config.py +++ b/deploy/Windows/config.py @@ -169,12 +169,15 @@ class DeployConfig(ConfigModel): @cached_property def python(self) -> str: - exe = self.filepath(self.PythonExecutable) - if os.path.exists(exe): - return exe + # No need to read PythonExecutable + # since you run this code with python, current python is the python + + # exe = self.filepath(self.PythonExecutable) + # if os.path.exists(exe): + # return exe current = sys.executable.replace("\\", "/") - logger.warning(f'PythonExecutable: {exe} does not exist, use current python instead: {current}') + # logger.warning(f'PythonExecutable: {exe} does not exist, use current python instead: {current}') return current @cached_property diff --git a/deploy/Windows/pip.py b/deploy/Windows/pip.py index cedb0a1..e8afe06 100644 --- a/deploy/Windows/pip.py +++ b/deploy/Windows/pip.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from urllib.parse import urlparse from deploy.Windows.config import DeployConfig -from deploy.Windows.logger import logger, Progress +from deploy.Windows.logger import Progress, logger from deploy.Windows.utils import cached_property @@ -46,9 +46,15 @@ class PipManager(DeployConfig): return f'"{self.python}" -m pip' @cached_property - def python_site_packages(self): - return os.path.abspath(os.path.join(self.python, '../Lib/site-packages')) \ - .replace(r"\\", "/").replace("\\", "/") + def python_site_packages(self) -> str: + import site + paths = site.getsitepackages() + # site-packages should be site-packages folder + for path in paths: + if path.endswith('site-packages'): + return path + # Otherwise pick first + return paths[0] @cached_property def set_installed_dependency(self) -> t.Set[DataDependency]: