"""Pip arguments for bootstrap install modes. Generated by AI/LLM: 2026-09-30 - local and no-env install options. SPEC 7.24. Both ``bootstrap`` and ``bootstrap.ps1`` call this script and read one pip argument per stdout line. """ import argparse import sys def pip_install_args( *, local: bool, no_env: bool, break_system_packages: bool = False, ) -> list[str]: """Return the arguments passed to ``python -m pip``. Args: local: Install this repository as a normal package. When false, the install is editable and includes the ``dev`` extra. no_env: Add ``--user`` so the install does not need a virtual environment. break_system_packages: Add ``--break-system-packages``. Bash sets this. PowerShell does not. Returns: The pip argument list, starting with ``install``. """ args = ["install"] if no_env: args.append("--user") if break_system_packages: args.append("--break-system-packages") if local: args.append(".") else: args.extend(["-e", ".[dev]"]) return args def main(argv: list[str] | None = None) -> int: """Print pip arguments, one per line. Args: argv: Flags to parse. ``None`` reads ``sys.argv``. Returns: Process exit code. ``0`` after the arguments are written. """ parser = argparse.ArgumentParser( description="Print pip install arguments for bootstrap.", ) parser.add_argument( "--local", action="store_true", help="install this repository as a normal package", ) parser.add_argument( "--no-env", action="store_true", help="add --user so no virtual environment is required", ) parser.add_argument( "--break-system-packages", action="store_true", help="pass --break-system-packages to pip", ) parsed = parser.parse_args(argv) words = pip_install_args( local=parsed.local, no_env=parsed.no_env, break_system_packages=parsed.break_system_packages, ) sys.stdout.write("\n".join(words) + "\n") return 0 if __name__ == "__main__": sys.exit(main())