piptools._compat package

Submodules

Module contents

class piptools._compat.Distribution(key: 'str', version: 'str', requires: 'Iterable[Requirement]', direct_url: 'DirectUrl | None')

Bases: object

classmethod _from_importlib(dist: _ImportLibDist) Distribution

Mimic pkg_resources.Distribution.requires for the case of no extras.

This doesn’t fulfill that API’s extras parameter but satisfies the needs of pip-tools.

classmethod _from_pkg_resources(dist: Distribution) Distribution
direct_url: DirectUrl | None
classmethod from_pip_distribution(dist: BaseDistribution) Distribution
key: str
requires: Iterable[Requirement]
version: str
piptools._compat.canonicalize_name(name: str, *, validate: bool = False) NormalizedName

This function takes a valid Python package or extra name, and returns the normalized form of it.

The return type is typed as NormalizedName. This allows type checkers to help require that a string has passed through this function before use.

If validate is true, then the function will check if name is a valid distribution name before normalizing.

Parameters:
  • name (str) – The name to normalize.

  • validate (bool) – Check whether the name is a valid distribution name.

Raises:

InvalidName – If validate is true and the name is not an acceptable distribution name.

>>> from packaging.utils import canonicalize_name
>>> canonicalize_name("Django")
'django'
>>> canonicalize_name("oslo.concurrency")
'oslo-concurrency'
>>> canonicalize_name("requests")
'requests'
piptools._compat.create_wheel_cache(cache_dir: str, format_control: str | None = None) WheelCache
piptools._compat.get_dev_pkgs() set[str]
piptools._compat.parse_requirements(filename: str, session: PipSession, finder: PackageFinder | None = None, options: Values | None = None, constraint: bool = False, isolated: bool = False, comes_from_stdin: bool = False) Iterator[InstallRequirement]