piptools.sync module#

piptools.sync.dependency_tree(installed_keys: Mapping[str, Distribution], root_key: str) set[str]#

Calculate the dependency tree for a package.

Return a collection of all of the package’s dependencies. Uses a DFS traversal algorithm.

installed_keys should be a {key: requirement} mapping, e.g. {‘django’: from_line(‘django==1.8’)} :param root_key: the key to return the dependency tree for :type root_key: str

piptools.sync.diff(compiled_requirements: Iterable[InstallRequirement], installed_dists: Iterable[Distribution]) tuple[set[InstallRequirement], set[str]]#

Calculate which packages should be installed or uninstalled.

Compared are the compiled requirements and a list of currently installed modules.

piptools.sync.diff_key_from_ireq(ireq: InstallRequirement) str#

Calculate key for comparing a compiled requirement with installed modules.

For URL requirements, only provide a useful key if the url includes a hash, e.g. #sha1=…, in any of the supported hash algorithms. Otherwise return ireq.link so the key will not match and the package will reinstall. Reinstall is necessary to ensure that packages will reinstall if the contents at the URL have changed but the version has not.

piptools.sync.diff_key_from_req(req: Distribution) str#

Get a unique key for the requirement.

piptools.sync.get_dists_to_ignore(installed: Iterable[Distribution]) list[str]#

Return a collection of package names to ignore by pip-sync.

Based on the currently installed environment. For example, when pip-tools is installed in the local environment, it should be ignored, including all of its dependencies (e.g. click). When pip-tools is not installed locally, click should also be installed/uninstalled depending on the given requirements.

piptools.sync.merge(requirements: Iterable[InstallRequirement], ignore_conflicts: bool) ValuesView[InstallRequirement]#
piptools.sync.sync(to_install: Iterable[InstallRequirement], to_uninstall: Iterable[InstallRequirement], dry_run: bool = False, install_flags: list[str] | None = None, ask: bool = False, python_executable: str | None = None) int#

Install and uninstall the given sets of modules.