Synchronize virtual environment with requirements.txt.
(
ask: bool,
dry_run: bool,
force: bool,
find_links: tuple[str, ...],
index_url: str | None,
extra_index_url: tuple[str, ...],
trusted_host: tuple[str, ...],
no_index: bool,
python_executable: str | None,
verbose: int,
quiet: int,
user_only: bool,
cert: str | None,
client_cert: str | None,
src_files: tuple[str, ...],
pip_args_str: str | None,
config: Path | None,
no_config: bool,
)
| 54 | @options.config |
| 55 | @options.no_config |
| 56 | def cli( |
| 57 | ask: bool, |
| 58 | dry_run: bool, |
| 59 | force: bool, |
| 60 | find_links: tuple[str, ...], |
| 61 | index_url: str | None, |
| 62 | extra_index_url: tuple[str, ...], |
| 63 | trusted_host: tuple[str, ...], |
| 64 | no_index: bool, |
| 65 | python_executable: str | None, |
| 66 | verbose: int, |
| 67 | quiet: int, |
| 68 | user_only: bool, |
| 69 | cert: str | None, |
| 70 | client_cert: str | None, |
| 71 | src_files: tuple[str, ...], |
| 72 | pip_args_str: str | None, |
| 73 | config: Path | None, |
| 74 | no_config: bool, |
| 75 | ) -> None: |
| 76 | """Synchronize virtual environment with requirements.txt.""" |
| 77 | log.verbosity = verbose - quiet |
| 78 | |
| 79 | if not src_files: |
| 80 | if os.path.exists(DEFAULT_REQUIREMENTS_FILE): |
| 81 | src_files = (DEFAULT_REQUIREMENTS_FILE,) |
| 82 | else: |
| 83 | msg = "No requirement files given and no {} found in the current directory" |
| 84 | log.error(msg.format(DEFAULT_REQUIREMENTS_FILE)) |
| 85 | sys.exit(2) |
| 86 | |
| 87 | if any(src_file.endswith(".in") for src_file in src_files): |
| 88 | msg = ( |
| 89 | "Some input files have the .in extension, which is most likely an error " |
| 90 | "and can cause weird behaviour. You probably meant to use " |
| 91 | "the corresponding *.txt file?" |
| 92 | ) |
| 93 | if force: |
| 94 | log.warning("WARNING: " + msg) |
| 95 | else: |
| 96 | log.error("ERROR: " + msg) |
| 97 | sys.exit(2) |
| 98 | |
| 99 | if config: |
| 100 | log.debug(f"Using pip-tools configuration defaults found in '{config !s}'.") |
| 101 | |
| 102 | if python_executable: |
| 103 | _validate_python_executable(python_executable) |
| 104 | |
| 105 | install_command = _t.cast(InstallCommand, create_command("install")) |
| 106 | options, _ = install_command.parse_args([]) |
| 107 | session = install_command._build_session(options) |
| 108 | finder = install_command._build_package_finder(options=options, session=session) |
| 109 | |
| 110 | # Parse requirements file. Note, all options inside requirements file |
| 111 | # will be collected by the finder. |
| 112 | requirements = flat_map( |
| 113 | lambda src: parse_requirements(src, finder=finder, session=session), src_files |
nothing calls this directly
no test coverage detected