Hello community,
here is the log from the commit of package python-importlib-metadata for
openSUSE:Factory checked in at 2020-01-20 22:49:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-importlib-metadata (Old)
and /work/SRC/openSUSE:Factory/.python-importlib-metadata.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-importlib-metadata"
Mon Jan 20 22:49:54 2020 rev:8 rq:765189 version:1.4.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-importlib-metadata/python-importlib-metadata.changes
2019-09-23 12:08:52.853890801 +0200
+++
/work/SRC/openSUSE:Factory/.python-importlib-metadata.new.26092/python-importlib-metadata.changes
2020-01-20 22:50:12.731222741 +0100
@@ -1,0 +2,19 @@
+Fri Jan 17 09:33:46 UTC 2020 - Marketa Calabkova <[email protected]>
+
+- update to 1.4.0
+ * Renamed package parameter to distribution_name.
+ * For better compatibility with the stdlib implementation and to
+ avoid the same distributions being discovered by the stdlib
+ and backport implementations, the backport now disables the
+ stdlib DistributionFinder during initialization (import time).
+ * Project adopts semver for versioning.
+ * EntryPoints are now pickleable.
+ * Dropped support for Python 3.4.
+ * Fixed repr(EntryPoint) on PyPy.
+ * Repaired project metadata to correctly declare the python_requires
directive.
+ * Through careful optimization, distribution() is 3-4x faster.
+ * When searching through sys.path, if any error occurs attempting
+ to list a path entry, that entry is skipped, making the system
+ much more lenient to errors.
+
+-------------------------------------------------------------------
Old:
----
importlib_metadata-0.21.tar.gz
New:
----
importlib_metadata-1.4.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-importlib-metadata.spec ++++++
--- /var/tmp/diff_new_pack.hK1Mbj/_old 2020-01-20 22:50:14.423223392 +0100
+++ /var/tmp/diff_new_pack.hK1Mbj/_new 2020-01-20 22:50:14.423223392 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-importlib-metadata
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -21,7 +21,7 @@
%define skip_python3 1
%endif
Name: python-importlib-metadata
-Version: 0.21
+Version: 1.4.0
Release: 0
Summary: Tool to read metadata from Python packages
License: Apache-2.0
@@ -37,7 +37,7 @@
BuildRequires: fdupes
BuildRequires: python-importlib_resources
BuildRequires: python-rpm-macros
-BuildRequires: python2-configparser
+BuildRequires: python2-configparser >= 3.5
BuildRequires: python2-contextlib2
Requires: python-zipp >= 0.5
Provides: python-importlib_metadata = %{version}
@@ -50,11 +50,8 @@
%else
BuildRequires: python-pathlib2
%endif
-%if %{python3_version_nodots} < 35
-Requires: python-pathlib2
-%endif
%ifpython2
-Requires: python-configparser
+Requires: python-configparser >= 3.5
Requires: python-contextlib2
Requires: python-pathlib2
%endif
++++++ importlib_metadata-0.21.tar.gz -> importlib_metadata-1.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_metadata-0.21/.gitlab-ci.yml
new/importlib_metadata-1.4.0/.gitlab-ci.yml
--- old/importlib_metadata-0.21/.gitlab-ci.yml 2019-09-10 13:38:27.000000000
+0200
+++ new/importlib_metadata-1.4.0/.gitlab-ci.yml 2020-01-11 01:18:29.000000000
+0100
@@ -13,18 +13,18 @@
tests:
script:
- - tox -e py27,py34,py35,py36,py37,py38
+ - tox -e py27,py35,py36,py37,py38
coverage:
script:
- - tox -e py27-cov,py34-cov,py35-cov,py36-cov,py37-cov,py38-cov
+ - tox -e py27-cov,py35-cov,py36-cov,py37-cov,py38-cov
artifacts:
paths:
- coverage.xml
diffcov:
script:
- - tox -e
py27-diffcov,py34-diffcov,py35-diffcov,py36-diffcov,py37-diffcov,py38-diffcov
+ - tox -e py27-diffcov,py35-diffcov,py36-diffcov,py37-diffcov,py38-diffcov
docs:
script:
@@ -41,6 +41,6 @@
release:
stage: deploy
only:
- - /^\d+\.\d+(\.\d+)?([abc]\d*)?$/
+ - /^v\d+\.\d+(\.\d+)?([abc]\d*)?$/
script:
- tox -e release
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_metadata-0.21/PKG-INFO
new/importlib_metadata-1.4.0/PKG-INFO
--- old/importlib_metadata-0.21/PKG-INFO 2019-09-10 13:38:52.000000000
+0200
+++ new/importlib_metadata-1.4.0/PKG-INFO 2020-01-11 01:18:51.000000000
+0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: importlib_metadata
-Version: 0.21
+Version: 1.4.0
Summary: Read metadata from Python packages
Home-page: http://importlib-metadata.readthedocs.io/
Author: Barry Warsaw
@@ -50,6 +50,6 @@
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2
-Requires-Python: >=2.7,!=3.0,!=3.1,!=3.2,!=3.3
-Provides-Extra: docs
+Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
Provides-Extra: testing
+Provides-Extra: docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/__init__.py
new/importlib_metadata-1.4.0/importlib_metadata/__init__.py
--- old/importlib_metadata-0.21/importlib_metadata/__init__.py 2019-09-10
13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/__init__.py 2020-01-11
01:18:29.000000000 +0100
@@ -10,6 +10,7 @@
import operator
import functools
import itertools
+import posixpath
import collections
from ._compat import (
@@ -23,11 +24,10 @@
NotADirectoryError,
PermissionError,
pathlib,
- PYPY_OPEN_BUG,
ModuleNotFoundError,
MetaPathFinder,
email_message_from_string,
- ensure_is_path,
+ PyPy_repr,
)
from importlib import import_module
from itertools import starmap
@@ -54,7 +54,9 @@
"""The package was not found."""
-class EntryPoint(collections.namedtuple('EntryPointBase', 'name value group')):
+class EntryPoint(
+ PyPy_repr,
+ collections.namedtuple('EntryPointBase', 'name value group')):
"""An entry point as defined by Python packaging conventions.
See `the packaging docs on entry points
@@ -124,6 +126,12 @@
"""
return iter((self.name, self))
+ def __reduce__(self):
+ return (
+ self.__class__,
+ (self.name, self.value, self.group),
+ )
+
class PackagePath(pathlib.PurePosixPath):
"""A reference to a path in a package"""
@@ -211,7 +219,7 @@
:param path: a string or path-like object
:return: a concrete Distribution instance for the path
"""
- return PathDistribution(ensure_is_path(path))
+ return PathDistribution(pathlib.Path(path))
@staticmethod
def _discover_resolvers():
@@ -351,10 +359,21 @@
"""
class Context:
+ """
+ Keyword arguments presented by the caller to
+ ``distributions()`` or ``Distribution.discover()``
+ to narrow the scope of a search for distributions
+ in all DistributionFinders.
+
+ Each DistributionFinder may expect any parameters
+ and should attempt to honor the canonical
+ parameters defined below when appropriate.
+ """
name = None
"""
Specific name for which a distribution finder should match.
+ A name of ``None`` matches all distributions.
"""
def __init__(self, **kwargs):
@@ -364,13 +383,12 @@
def path(self):
"""
The path that a distribution finder should search.
+
+ Typically refers to Python package paths and defaults
+ to ``sys.path``.
"""
return vars(self).get('path', sys.path)
- @property
- def pattern(self):
- return '.*' if self.name is None else re.escape(self.name)
-
@abc.abstractmethod
def find_distributions(self, context=Context()):
"""
@@ -382,6 +400,73 @@
"""
+class FastPath:
+ """
+ Micro-optimized class for searching a path for
+ children.
+ """
+
+ def __init__(self, root):
+ self.root = root
+
+ def joinpath(self, child):
+ return pathlib.Path(self.root, child)
+
+ def children(self):
+ with suppress(Exception):
+ return os.listdir(self.root or '')
+ with suppress(Exception):
+ return self.zip_children()
+ return []
+
+ def zip_children(self):
+ zip_path = zipp.Path(self.root)
+ names = zip_path.root.namelist()
+ self.joinpath = zip_path.joinpath
+
+ return (
+ posixpath.split(child)[0]
+ for child in names
+ )
+
+ def is_egg(self, search):
+ root_n_low = os.path.split(self.root)[1].lower()
+
+ return (
+ root_n_low == search.normalized + '.egg'
+ or root_n_low.startswith(search.prefix)
+ and root_n_low.endswith('.egg'))
+
+ def search(self, name):
+ for child in self.children():
+ n_low = child.lower()
+ if (n_low in name.exact_matches
+ or n_low.startswith(name.prefix)
+ and n_low.endswith(name.suffixes)
+ # legacy case:
+ or self.is_egg(name) and n_low == 'egg-info'):
+ yield self.joinpath(child)
+
+
+class Prepared:
+ """
+ A prepared search for metadata on a possibly-named package.
+ """
+ normalized = ''
+ prefix = ''
+ suffixes = '.dist-info', '.egg-info'
+ exact_matches = [''][:0]
+
+ def __init__(self, name):
+ self.name = name
+ if name is None:
+ return
+ self.normalized = name.lower().replace('-', '_')
+ self.prefix = self.normalized + '-'
+ self.exact_matches = [
+ self.normalized + suffix for suffix in self.suffixes]
+
+
@install
class MetadataPathFinder(NullFinder, DistributionFinder):
"""A degenerate finder for distribution packages on the file system.
@@ -399,45 +484,17 @@
(or all names if ``None`` indicated) along the paths in the list
of directories ``context.path``.
"""
- found = self._search_paths(context.pattern, context.path)
+ found = self._search_paths(context.name, context.path)
return map(PathDistribution, found)
@classmethod
- def _search_paths(cls, pattern, paths):
+ def _search_paths(cls, name, paths):
"""Find metadata directories in paths heuristically."""
return itertools.chain.from_iterable(
- cls._search_path(path, pattern)
- for path in map(cls._switch_path, paths)
+ path.search(Prepared(name))
+ for path in map(FastPath, paths)
)
- @staticmethod
- def _switch_path(path):
- if not PYPY_OPEN_BUG or os.path.isfile(path): # pragma: no branch
- with suppress(Exception):
- return zipp.Path(path)
- return pathlib.Path(path)
-
- @classmethod
- def _matches_info(cls, normalized, item):
- template = r'{pattern}(-.*)?\.(dist|egg)-info'
- manifest = template.format(pattern=normalized)
- return re.match(manifest, item.name, flags=re.IGNORECASE)
-
- @classmethod
- def _matches_legacy(cls, normalized, item):
- template = r'{pattern}-.*\.egg[\\/]EGG-INFO'
- manifest = template.format(pattern=normalized)
- return re.search(manifest, str(item), flags=re.IGNORECASE)
-
- @classmethod
- def _search_path(cls, root, pattern):
- if not root.is_dir():
- return ()
- normalized = pattern.replace('-', '_')
- return (item for item in root.iterdir()
- if cls._matches_info(normalized, item)
- or cls._matches_legacy(normalized, item))
-
class PathDistribution(Distribution):
def __init__(self, path):
@@ -458,13 +515,13 @@
return self._path.parent / path
-def distribution(package):
- """Get the ``Distribution`` instance for the given package.
+def distribution(distribution_name):
+ """Get the ``Distribution`` instance for the named package.
- :param package: The name of the package as a string.
+ :param distribution_name: The name of the distribution package as a string.
:return: A ``Distribution`` instance (or subclass thereof).
"""
- return Distribution.from_name(package)
+ return Distribution.from_name(distribution_name)
def distributions(**kwargs):
@@ -475,23 +532,23 @@
return Distribution.discover(**kwargs)
-def metadata(package):
- """Get the metadata for the package.
+def metadata(distribution_name):
+ """Get the metadata for the named package.
- :param package: The name of the distribution package to query.
+ :param distribution_name: The name of the distribution package to query.
:return: An email.Message containing the parsed metadata.
"""
- return Distribution.from_name(package).metadata
+ return Distribution.from_name(distribution_name).metadata
-def version(package):
+def version(distribution_name):
"""Get the version string for the named package.
- :param package: The name of the distribution package to query.
+ :param distribution_name: The name of the distribution package to query.
:return: The version string for the package as defined in the package's
"Version" metadata key.
"""
- return distribution(package).version
+ return distribution(distribution_name).version
def entry_points():
@@ -510,18 +567,23 @@
}
-def files(package):
- return distribution(package).files
+def files(distribution_name):
+ """Return a list of files for the named package.
+
+ :param distribution_name: The name of the distribution package to query.
+ :return: List of files composing the distribution.
+ """
+ return distribution(distribution_name).files
-def requires(package):
+def requires(distribution_name):
"""
- Return a list of requirements for the indicated distribution.
+ Return a list of requirements for the named package.
:return: An iterator of requirements, suitable for
packaging.requirement.Requirement.
"""
- return distribution(package).requires
+ return distribution(distribution_name).requires
__version__ = version(__name__)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/_compat.py
new/importlib_metadata-1.4.0/importlib_metadata/_compat.py
--- old/importlib_metadata-0.21/importlib_metadata/_compat.py 2019-09-10
13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/_compat.py 2020-01-11
01:18:29.000000000 +0100
@@ -51,11 +51,35 @@
def install(cls):
- """Class decorator for installation on sys.meta_path."""
+ """
+ Class decorator for installation on sys.meta_path.
+
+ Adds the backport DistributionFinder to sys.meta_path and
+ attempts to disable the finder functionality of the stdlib
+ DistributionFinder.
+ """
sys.meta_path.append(cls())
+ disable_stdlib_finder()
return cls
+def disable_stdlib_finder():
+ """
+ Give the backport primacy for discovering path-based distributions
+ by monkey-patching the stdlib O_O.
+
+ See #91 for more background for rationale on this sketchy
+ behavior.
+ """
+ def matches(finder):
+ return (
+ finder.__module__ == '_frozen_importlib_external'
+ and hasattr(finder, 'find_distributions')
+ )
+ for finder in filter(matches, sys.meta_path): # pragma: nocover
+ del finder.find_distributions
+
+
class NullFinder:
"""
A "Finder" (aka "MetaClassFinder") that never finds any modules,
@@ -87,14 +111,21 @@
email.message_from_string
)
-#
https://bitbucket.org/pypy/pypy/issues/3021/ioopen-directory-leaks-a-file-descriptor
-PYPY_OPEN_BUG = getattr(sys, 'pypy_version_info', (9, 9, 9))[:3] <= (7, 1, 1)
-
-def ensure_is_path(ob):
- """Construct a Path from ob even if it's already one.
- Specialized for Python 3.4.
+class PyPy_repr:
"""
- if (3,) < sys.version_info < (3, 5):
- ob = str(ob) # pragma: nocover
- return pathlib.Path(ob)
+ Override repr for EntryPoint objects on PyPy to avoid __iter__ access.
+ Ref #97, #102.
+ """
+ affected = hasattr(sys, 'pypy_version_info')
+
+ def __compat_repr__(self): # pragma: nocover
+ def make_param(name):
+ value = getattr(self, name)
+ return '{name}={value!r}'.format(**locals())
+ params = ', '.join(map(make_param, self._fields))
+ return 'EntryPoint({params})'.format(**locals())
+
+ if affected: # pragma: nocover
+ __repr__ = __compat_repr__
+ del affected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/docs/changelog.rst
new/importlib_metadata-1.4.0/importlib_metadata/docs/changelog.rst
--- old/importlib_metadata-0.21/importlib_metadata/docs/changelog.rst
2019-09-10 13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/docs/changelog.rst
2020-01-11 01:18:29.000000000 +0100
@@ -2,6 +2,79 @@
importlib_metadata NEWS
=========================
+v1.4.0
+======
+
+* Through careful optimization, ``distribution()`` is
+ 3-4x faster. Thanks to Antony Lee for the
+ contribution. Closes #95.
+
+v1.3.0
+======
+
+* Improve custom finders documentation. Closes #105.
+
+v1.2.0
+======
+
+* Once again, drop support for Python 3.4. Ref #104.
+
+v1.1.3
+======
+
+* Restored support for Python 3.4 due to improper version
+ compatibility declarations in the v1.1.0 and v1.1.1
+ releases. Closes #104.
+
+v1.1.2
+======
+
+* Repaired project metadata to correctly declare the
+ ``python_requires`` directive. Closes #103.
+
+v1.1.1
+======
+
+* Fixed ``repr(EntryPoint)`` on PyPy 3 also. Closes #102.
+
+v1.1.0
+======
+
+* Dropped support for Python 3.4.
+* EntryPoints are now pickleable. Closes #96.
+* Fixed ``repr(EntryPoint)`` on PyPy 2. Closes #97.
+
+v1.0.0
+======
+
+* Project adopts semver for versioning.
+
+* Removed compatibility shim introduced in 0.23.
+
+* For better compatibility with the stdlib implementation and to
+ avoid the same distributions being discovered by the stdlib and
+ backport implementations, the backport now disables the
+ stdlib DistributionFinder during initialization (import time).
+ Closes #91 and closes #100.
+
+0.23
+====
+* Added a compatibility shim to prevent failures on beta releases
+ of Python before the signature changed to accept the
+ "context" parameter on find_distributions. This workaround
+ will have a limited lifespan, not to extend beyond release of
+ Python 3.8 final.
+
+0.22
+====
+* Renamed ``package`` parameter to ``distribution_name``
+ as `recommended <https://bugs.python.org/issue34632#msg349423>`_
+ in the following functions: ``distribution``, ``metadata``,
+ ``version``, ``files``, and ``requires``. This
+ backward-incompatible change is expected to have little impact
+ as these functions are assumed to be primarily used with
+ positional parameters.
+
0.21
====
* ``importlib.metadata`` now exposes the ``DistributionFinder``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/docs/conf.py
new/importlib_metadata-1.4.0/importlib_metadata/docs/conf.py
--- old/importlib_metadata-0.21/importlib_metadata/docs/conf.py 2019-09-10
13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/docs/conf.py
2020-01-11 01:18:29.000000000 +0100
@@ -166,6 +166,9 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
+ 'importlib_resources': (
+ 'https://importlib-resources.readthedocs.io/en/latest/', None
+ ),
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/docs/index.rst
new/importlib_metadata-1.4.0/importlib_metadata/docs/index.rst
--- old/importlib_metadata-0.21/importlib_metadata/docs/index.rst
2019-09-10 13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/docs/index.rst
2020-01-11 01:18:29.000000000 +0100
@@ -3,17 +3,18 @@
===============================
``importlib_metadata`` is a library which provides an API for accessing an
-installed package's `metadata`_, such as its entry points or its top-level
+installed package's metadata (see :pep:`566`), such as its entry points or its
top-level
name. This functionality intends to replace most uses of ``pkg_resources``
-`entry point API`_ and `metadata API`_. Along with ``importlib.resources`` in
-`Python 3.7 and newer`_ (backported as `importlib_resources`_ for older
+`entry point API`_ and `metadata API`_. Along with :mod:`importlib.resources`
in
+Python 3.7 and newer (backported as :doc:`importlib_resources
<importlib_resources:index>` for older
versions of Python), this can eliminate the need to use the older and less
efficient ``pkg_resources`` package.
``importlib_metadata`` is a backport of Python 3.8's standard library
-`importlib.metadata`_ module for Python 2.7, and 3.4 through 3.7. Users of
-Python 3.8 and beyond are encouraged to use the standard library module, and
-in fact for these versions, ``importlib_metadata`` just shadows that module.
+:doc:`importlib.metadata <library/importlib.metadata>` module for Python 2.7,
and 3.4 through 3.7. Users of
+Python 3.8 and beyond are encouraged to use the standard library module.
+When imported on Python 3.8 and later, ``importlib_metadata`` replaces the
+DistributionFinder behavior from the stdlib, but leaves the API in tact.
Developers looking for detailed API descriptions should refer to the Python
3.8 standard library documentation.
@@ -45,9 +46,5 @@
* :ref:`search`
-.. _`metadata`: https://www.python.org/dev/peps/pep-0566/
.. _`entry point API`:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
.. _`metadata API`:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api
-.. _`Python 3.7 and newer`:
https://docs.python.org/3/library/importlib.html#module-importlib.resources
-.. _`importlib_resources`:
https://importlib-resources.readthedocs.io/en/latest/index.html
-.. _`importlib.metadata`: TBD
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/docs/using.rst
new/importlib_metadata-1.4.0/importlib_metadata/docs/using.rst
--- old/importlib_metadata-0.21/importlib_metadata/docs/using.rst
2019-09-10 13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/docs/using.rst
2020-01-11 01:18:29.000000000 +0100
@@ -1,15 +1,15 @@
.. _using:
-==========================
- Using importlib_metadata
-==========================
+=================================
+ Using :mod:`!importlib_metadata`
+=================================
``importlib_metadata`` is a library that provides for access to installed
package metadata. Built in part on Python's import system, this library
intends to replace similar functionality in the `entry point
API`_ and `metadata API`_ of ``pkg_resources``. Along with
-``importlib.resources`` in `Python 3.7
-and newer`_ (backported as `importlib_resources`_ for older versions of
+:mod:`importlib.resources` in Python 3.7
+and newer (backported as :doc:`importlib_resources
<importlib_resources:index>` for older versions of
Python), this can eliminate the need to use the older and less efficient
``pkg_resources`` package.
@@ -17,9 +17,9 @@
Python's ``site-packages`` directory via tools such as `pip
<https://pypi.org/project/pip/>`_. Specifically,
it means a package with either a discoverable ``dist-info`` or ``egg-info``
-directory, and metadata defined by `PEP 566`_ or its older specifications.
+directory, and metadata defined by :pep:`566` or its older specifications.
By default, package metadata can live on the file system or in zip archives on
-``sys.path``. Through an extension mechanism, the metadata can live almost
+:data:`sys.path`. Through an extension mechanism, the metadata can live almost
anywhere.
@@ -127,7 +127,7 @@
You can also get the full set of files contained within a distribution. The
``files()`` function takes a distribution package name and returns all of the
files installed by this distribution. Each file object returned is a
-``PackagePath``, a `pathlib.Path`_ derived object with additional ``dist``,
+``PackagePath``, a :class:`pathlib.Path` derived object with additional
``dist``,
``size``, and ``hash`` properties as indicated by the metadata. For example::
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0]
@@ -196,18 +196,18 @@
>>> d.metadata['License']
'MIT'
-The full set of available metadata is not described here. See `PEP 566
-<https://www.python.org/dev/peps/pep-0566/>`_ for additional details.
+The full set of available metadata is not described here. See :pep:`566`
+for additional details.
Extending the search algorithm
==============================
-Because package metadata is not available through ``sys.path`` searches, or
+Because package metadata is not available through :data:`sys.path` searches, or
package loaders directly, the metadata for a package is found through import
system `finders`_. To find a distribution package's metadata,
-``importlib_metadata`` queries the list of `meta path finders`_ on
-`sys.meta_path`_.
+``importlib.metadata`` queries the list of :term:`meta path finders <meta path
finder>` on
+:data:`sys.meta_path`.
By default ``importlib_metadata`` installs a finder for distribution packages
found on the file system. This finder doesn't actually find any *packages*,
@@ -217,7 +217,7 @@
interface expected of finders by Python's import system.
``importlib_metadata`` extends this protocol by looking for an optional
``find_distributions`` callable on the finders from
-``sys.meta_path`` and presents this extended interface as the
+:data:`sys.meta_path` and presents this extended interface as the
``DistributionFinder`` abstract base class, which defines this abstract
method::
@@ -232,28 +232,21 @@
supply other relevant context.
What this means in practice is that to support finding distribution package
-metadata in locations other than the file system, you should derive from
-``Distribution`` and implement the ``load_metadata()`` method. Then from
-your finder, return instances of this derived ``Distribution`` in the
+metadata in locations other than the file system, subclass
+``Distribution`` and implement the abstract methods. Then from
+a custom finder, return instances of this derived ``Distribution`` in the
``find_distributions()`` method.
.. _`entry point API`:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
.. _`metadata API`:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api
-.. _`Python 3.7 and newer`:
https://docs.python.org/3/library/importlib.html#module-importlib.resources
-.. _`importlib_resources`:
https://importlib-resources.readthedocs.io/en/latest/index.html
-.. _`PEP 566`: https://www.python.org/dev/peps/pep-0566/
.. _`finders`:
https://docs.python.org/3/reference/import.html#finders-and-loaders
-.. _`meta path finders`:
https://docs.python.org/3/glossary.html#term-meta-path-finder
-.. _`sys.meta_path`: https://docs.python.org/3/library/sys.html#sys.meta_path
-.. _`pathlib.Path`: https://docs.python.org/3/library/pathlib.html#pathlib.Path
.. rubric:: Footnotes
.. [#f1] Technically, the returned distribution metadata object is an
- `email.message.Message
-
<https://docs.python.org/3/library/email.message.html#email.message.EmailMessage>`_
+ :class:`email.message.EmailMessage`
instance, but this is an implementation detail, and not part of the
stable API. You should only use dictionary-like methods and syntax
to access the metadata contents.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata/tests/test_main.py
new/importlib_metadata-1.4.0/importlib_metadata/tests/test_main.py
--- old/importlib_metadata-0.21/importlib_metadata/tests/test_main.py
2019-09-10 13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata/tests/test_main.py
2020-01-11 01:18:29.000000000 +0100
@@ -2,6 +2,8 @@
from __future__ import unicode_literals
import re
+import json
+import pickle
import textwrap
import unittest
import importlib
@@ -189,3 +191,34 @@
with self.add_sys_path(egg):
with self.assertRaises(PackageNotFoundError):
version('foo')
+
+
+class TestEntryPoints(unittest.TestCase):
+ def __init__(self, *args):
+ super(TestEntryPoints, self).__init__(*args)
+ self.ep = importlib_metadata.EntryPoint('name', 'value', 'group')
+
+ def test_entry_point_pickleable(self):
+ revived = pickle.loads(pickle.dumps(self.ep))
+ assert revived == self.ep
+
+ def test_immutable(self):
+ """EntryPoints should be immutable"""
+ with self.assertRaises(AttributeError):
+ self.ep.name = 'badactor'
+
+ def test_repr(self):
+ assert 'EntryPoint' in repr(self.ep)
+ assert 'name=' in repr(self.ep)
+ assert "'name'" in repr(self.ep)
+
+ def test_hashable(self):
+ """EntryPoints should be hashable"""
+ hash(self.ep)
+
+ def test_json_dump(self):
+ """
+ json should not expect to be able to dump an EntryPoint
+ """
+ with self.assertRaises(Exception):
+ json.dumps(self.ep)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata.egg-info/PKG-INFO
new/importlib_metadata-1.4.0/importlib_metadata.egg-info/PKG-INFO
--- old/importlib_metadata-0.21/importlib_metadata.egg-info/PKG-INFO
2019-09-10 13:38:51.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata.egg-info/PKG-INFO
2020-01-11 01:18:51.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: importlib-metadata
-Version: 0.21
+Version: 1.4.0
Summary: Read metadata from Python packages
Home-page: http://importlib-metadata.readthedocs.io/
Author: Barry Warsaw
@@ -50,6 +50,6 @@
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2
-Requires-Python: >=2.7,!=3.0,!=3.1,!=3.2,!=3.3
-Provides-Extra: docs
+Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
Provides-Extra: testing
+Provides-Extra: docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_metadata-0.21/importlib_metadata.egg-info/requires.txt
new/importlib_metadata-1.4.0/importlib_metadata.egg-info/requires.txt
--- old/importlib_metadata-0.21/importlib_metadata.egg-info/requires.txt
2019-09-10 13:38:51.000000000 +0200
+++ new/importlib_metadata-1.4.0/importlib_metadata.egg-info/requires.txt
2020-01-11 01:18:51.000000000 +0100
@@ -1,12 +1,10 @@
zipp>=0.5
[:python_version < "3"]
+pathlib2
contextlib2
configparser>=3.5
-[:python_version == "3.4.*" or python_version < "3"]
-pathlib2
-
[docs]
sphinx
rst.linker
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_metadata-0.21/setup.cfg
new/importlib_metadata-1.4.0/setup.cfg
--- old/importlib_metadata-0.21/setup.cfg 2019-09-10 13:38:52.000000000
+0200
+++ new/importlib_metadata-1.4.0/setup.cfg 2020-01-11 01:18:51.000000000
+0100
@@ -15,11 +15,11 @@
Programming Language :: Python :: 2
[options]
-python_requires = >=2.7,!=3.0,!=3.1,!=3.2,!=3.3
+python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
setup_requires = setuptools-scm
install_requires =
zipp>=0.5
- pathlib2; python_version=='3.4.*' or python_version < '3'
+ pathlib2; python_version < '3'
contextlib2; python_version < '3'
configparser>=3.5; python_version < '3'
packages = find:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_metadata-0.21/tox.ini
new/importlib_metadata-1.4.0/tox.ini
--- old/importlib_metadata-0.21/tox.ini 2019-09-10 13:38:27.000000000 +0200
+++ new/importlib_metadata-1.4.0/tox.ini 2020-01-11 01:18:29.000000000
+0100
@@ -1,5 +1,5 @@
[tox]
-envlist = {py27,py34,py35,py36,py37,py38}{,-cov,-diffcov},qa,docs
+envlist = {py27,py35,py36,py37,py38}{,-cov,-diffcov},qa,docs
skip_missing_interpreters = True
@@ -33,7 +33,7 @@
cov: COVERAGE_OPTIONS="-p"
cov: COVERAGE_FILE={toxinidir}/.coverage
py27: PYV=2
- py34,py35,py36,py37,py38: PYV=3
+ py35,py36,py37,py38: PYV=3
# workaround deprecation warnings in pip's vendored packages
PYTHONWARNINGS=ignore:Using or importing the
ABCs:DeprecationWarning:pip._vendor
extras =
@@ -69,8 +69,9 @@
keyring
setuptools_scm
passenv =
- TWINE_USERNAME
TWINE_PASSWORD
+setenv =
+ TWINE_USERNAME = {env:TWINE_USERNAME:__token__}
commands =
python setup.py sdist bdist_wheel
python -m twine {posargs} upload dist/*