mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
Update additional argument handling
This commit is contained in:
+14
-7
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user