From b37fff123724d6b088bc929708087b8e3f4676e4 Mon Sep 17 00:00:00 2001 From: awsr <43862868+awsr@users.noreply.github.com> Date: Tue, 28 Apr 2026 01:05:29 -0700 Subject: [PATCH] Update additional argument handling --- installer.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/installer.py b/installer.py index db8f423d7..caf874837 100644 --- a/installer.py +++ b/installer.py @@ -37,7 +37,7 @@ log = logging.getLogger('sdnext.installer') debug = log.debug if os.environ.get('SD_INSTALL_DEBUG', None) is not None else lambda *args, **kwargs: None setuptools, distutils = None, None # defined via ensure_base_requirements current_branch = None -pip_log = '--log pip.log ' if os.environ.get('SD_PIP_DEBUG', None) is not None else '' +pip_log = '--log pip.log' if os.environ.get('SD_PIP_DEBUG', None) is not None else '' main_directory = os.path.dirname(os.path.abspath(__file__)) log_file = os.path.join(main_directory, 'sdnext.log') hostname = socket.gethostname() @@ -248,7 +248,7 @@ def cleanup_broken_packages(): def pip(arg: str, ignore: bool = False, quiet: bool = True, uv = True) -> tuple[subprocess.CompletedProcess, str]: t_start = time.time() originalArg = arg - arg = arg.replace('>=', '==') + arg = arg.replace('>=', '==').strip() if opts.get('offline_mode', False): log.warning('Offline mode enabled') return None, 'offline' @@ -257,14 +257,21 @@ def pip(arg: str, ignore: bool = False, quiet: bool = True, uv = True) -> tuple[ pipCmd = "uv pip" if uv else "pip" if not quiet and '-r ' not in arg: log.info(f'Install: package="{package}" mode={"uv" if uv else "pip"}') - env_args = os.environ.get("PIP_EXTRA_ARGS", "") - all_args = f'{pip_log}{arg} {env_args}'.strip() + env_args = os.environ.get("PIP_EXTRA_ARGS", "").strip() + all_args: list[str] = [] + if pip_log: + all_args.append(pip_log) + all_args.append(arg) + if env_args: + all_args.append(env_args) if not quiet: - log.debug(f'Running: {pipCmd}="{all_args}"') - result, output = run(sys.executable, "-m", pipCmd, all_args) + log.debug(f'Running: {pipCmd}="{" ".join(all_args)}"') + + result, output = run(sys.executable, "-m", pipCmd, *all_args) + if len(result.stderr) > 0: if uv and result.returncode != 0: - log.warning(f'Install: cmd="{pipCmd}" args="{all_args}" cannot use uv, fallback to pip') + log.warning(f'Install: cmd="{pipCmd}" args="{" ".join(all_args)}" cannot use uv, fallback to pip') debug(f'Install: uv pip error: {result.stderr}') cleanup_broken_packages() return pip(originalArg, ignore, quiet, uv=False)