piptools._internal._pip_api package

Submodules

Module contents

The piptools._pip_api subpackage defines an API layer on top of pip internals and usage. It is a private API for the rest of piptools to leverage.

piptools._internal._pip_api.copy_install_requirement(template: InstallRequirement, **extra_kwargs: Any) InstallRequirement

Make a copy of a template InstallRequirement with extra kwargs.

piptools._internal._pip_api.create_install_requirement(name: str, version: str | Version, ireq: InstallRequirement) InstallRequirement
piptools._internal._pip_api.create_install_requirement_from_line(*args: Any, **kwargs: Any) InstallRequirement
piptools._internal._pip_api.finder_allows_all_prereleases(finder: PackageFinder) bool

Check if a package finder will get prereleases for all requirements.

On older pip versions, this is not specific to the requirement, but on newer ones it is. However, --pre is translated internally to ":all:" on those versions.

piptools._internal._pip_api.finder_allows_prereleases_of_req(finder: PackageFinder, ireq: InstallRequirement) bool

Check if a package finder will get prereleases for a given requirement.

On older pip versions, this is not specific to the requirement, but on newer ones it is.

piptools._internal._pip_api.get_pip_request_failed_exception_types() tuple[type[Exception], ...]

Get the error types which indicate a connection failure, as might be experienced by a client trying to reach an index server’s JSON API when that API is not available.

These are only the errors that indicate some kind of failure to connect. Errors about SSL configuration, etc, should not be included here, so that they raise all the way to the user.

This functionality is provided as a cached function rather than a constant to defer the work of attribute lookups until it is actually needed. This increases the resilience of some pip-tools usages to changes in pip, for when pip-tools is used with new and untested versions.

piptools._internal._pip_api.get_pip_version_for_python_executable(python_executable: str) Version

Return pip version for the given python executable.

piptools._internal._pip_api.make_requirement_preparer_from_command(command: RequirementCommand, /, *, temp_build_dir: TempDirectory, options: Values, build_tracker: BuildTracker, session: PipSession, finder: PackageFinder, download_dir: str | None = None) RequirementPreparer

Wrap RequirementCommand.make_requirement_preparer() to be compatible across pip versions. Also pre-fill values which are fixed constants within pip-tools.

piptools._internal._pip_api.postprocess_cli_options(options: Values) None

After CLI parsing, pip processes options further to check various constraints and coalesce values. Emulate and/or invoke those same behaviors.