Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
importlib_metadata 8.7.2.dev1+gd8a7576de documentation
importlib_metadata 8.7.2.dev1+gd8a7576de documentation

Links

Back to top

Migration guide

The following guide will help you migrate commonpkg_resourcesAPIs toimportlib_metadata.importlib_metadata aims toreplace the followingpkg_resources APIs:

  • pkg_resources.iter_entry_points()

  • pkg_resources.require()

  • convenience functions

  • pkg_resources.find_distributions()

  • pkg_resources.get_distribution()

Other functionality frompkg_resources is replaced by otherpackages such asimportlib_resourcesandpackaging.

pkg_resources.iter_entry_points()

importlib_metadata providesEntry points.

Compatibility note: entry points provided by importlib_metadatado not have the following implicit behaviors found in thosefrompkg_resources:

  • Each EntryPoint is not automatically validated to match. Toensure each one is validated, invoke any property on theobject (e.g.ep.name).

  • When invokingEntryPoint.load(), no checks are performedto ensure the declared extras are installed. If this behavioris desired/required, it is left to the user to perform thecheck and install any dependencies. Seeimportlib_metadata#368for more details.

pkg_resources.require()

importlib_metadata does not provide support for dynamicallydiscovering or requiring distributions nor does it provide anysupport for managing the “working set”. Furthermore,importlib_metadata assumes that only one version of a givendistribution is discoverable at any time (no support for multi-versioninstalls). Any projects that require the above behavior needs toprovide that behavior independently.

importlib_metadata does aim to resolve metadata concerns latesuch that any dynamic changes to package availability should bereflected immediately.

Convenience functions

In addition to the support for direct access toDistributionobjects (below),importlib_metadata presents some top-levelfunctions for easy access to the most common metadata:

pkg_resources.find_distributions()

importlib_metadata provides functionalitysimilar tofind_distributions(). Bothdistributions(...) andDistribution.discover(...) return an iterable ofDistributionsmatching the indicated parameters.

pkg_resources.get_distribution()

Similar todistributions, thedistribution() function providesaccess to a single distribution by name.

On this page

[8]ページ先頭

©2009-2026 Movatter.jp