Plugins

Added in version 0.4.0.

Warning

Plugins are new and have not been tested througfully. There might be bugs, missing features and rough edges.

We encourage you to try them out and report any issues you might find.

If you create your own plugins, expect them to break when you update rez-pip’s minor version. The plugin system is still in its early stages and we will probably release breaking changes in the future.

rez-pip can be extended using plugins. Plugins can be used to do various things, such as modifying packages (both metadata and files), etc.

This page documents the hooks available to plugins and how to implement plugins.

List installed plugins

To list all installed plugins, use the rez pip2 --list-plugins command line argument.

Register a plugin

rez-pip’s plugin system is based on the pluggy framework, and as such, plugins must be registered using entry points.

The entry point group is named rez-pip.

In a pyproject.toml file, it can be set like this:

pyproject.toml
[project.entry-points."rez-pip"]
my_plugin = "my_plugin_module"

Functions

@rez_pip.plugins.hookimpl

Decorator used to register a plugin hook.

Hooks

The list of available hooks is provided below. They are listed in the order they are called by rez-pip.

prePipResolve(packages: tuple[str, ...], requirements: tuple[str, ...]) None

The pre-pip resolve hook allows a plugin to run some checks before resolving the requested packages using pip. The hook must not modify the content of the arguments passed to it.

Some use cases are allowing or disallowing the installation of some packages.

Parameters:
  • packages – List of packages requested by the user.

  • requirements – List of requirements files if any.

postPipResolve(packages: tuple[PackageInfo, ...]) None

The post-pip resolve hook allows a plugin to run some checks after resolving the requested packages using pip. The hook must not modify the content of the arguments passed to it.

Some use cases are allowing or disallowing the installation of some packages.

Parameters:

packages – List of resolved packages.

groupPackages(packages: collections.abc.MutableSequence[PackageInfo]) collections.abc.Sequence[PackageGroup[DownloadedArtifact]]

Merge packages into groups of packages. The name and version of the first package in the group will be used as the name and version for the rez package.

The hook must pop grouped packages out of the “packages” variable.

Parameters:

packages – List of resolved packages.

Returns:

A list of package groups.

cleanup(dist: Distribution, path: str) collections.abc.Sequence[CleanupAction]

Cleanup a package post-installation. Do not delete any files/directories from this hook. Return the list of actions you want to perform and let rez-pip perform them.

Parameters:
  • dist – Python distribution.

  • path – Root path of the rez variant.

patches(dist: Distribution, path: str) collections.abc.Sequence[str]

Provide paths to patches to be applied on the source code of a package.

Parameters:
  • dist – Python distribution.

  • path – Root path of the installed content.

metadata(package: PackageMaker) None

Modify/inject metadata in the rez package. The plugin is expected to modify “package” in place.

Parameters:

package – An insatnce of rez.package_maker.PackageMaker.

Built-in plugins

rez-pip comes with some built-in plugins that are enabled by default. They exists mostly to fix packages that are known to be “broken” if we don’t fix them using plugins.

This lists the plugin names and the hooks they implement.