This section has information on migrating from older APIs.
This has no direct analogue, but you can achieve equivalent results by doing something like the following:
from distlib import resources
resources.cache = resources.Cache(extraction_path)
before accessing the file_path property of any Resource. Note that if you have accessed the file_path property for a resource before doing this, the cache may already have extracted files.
This is not actually implemented in pkg_resources – it’s a no-op. You could achieve the analogous result using:
from distlib import resources
not_removed = resources.cache.clear()
You can provide an XXXResourceFinder class which finds resources in custom storage containers, and works like ResourceFinder. Although it shouldn’t be necessary, you could also return a subclass of Resource from your finders, to deal with custom requirements which aren’t catered for.
Entry points in pkg_resources are equivalent to per-distribution exports dictionary (see Exporting things from Distributions). The keys to the dictionary are just names in a hierarchical namespace delineated with periods (like Python packages). These keys are called groups in pkg_resources documentation, though that term is a little ambiguous. In Eclipse, for example, they are called extension point IDs, which is a little closer to the intended usage, but a bit of a mouthful. In distlib, we’ll use the term category or export category.
In distlib, the implementation of exports is slightly different from entry points of pkg_resources. A Distribution instance has an exports attribute, which is a dictionary keyed by category and whose values are dictionaries that map names to ExportEntry instances.
Below are the pkg_resources functions and how to achieve the equivalent in distlib. In cases where the pkg_resources functions take distribution names, in distlib you get the corresponding Distribution instance, using:
dist = dist_path.get_distribution(distname)
and then ask that instance (or the dist_path instance) for the things you need.