Skip to content

[BUG] Vendoring of importlib_metadata is shadowing actual package #3113

@sphuber

Description

@sphuber

setuptools version

setuptools==60.9.1

Python version

Python 3.8 and Python 3.9

OS

Ubuntu 20.04

Additional environment information

No response

Description

Since setuptools started vendoring importlib_metadata it is shadowing the actual package. This means that the type of entry points are no longer the class provided by the original importlib_metadata but the vendored package instead. Example:

Expected behavior

Installing setuptools should not have its vendored library shadow the real one changing the types returned by functions of the importlib_metadata package.

How to Reproduce

  1. Install setuptools>=60.9.0 in Python 3.8 or Python 3.9

Output

Behavior of setuptools==60.8

Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import setuptools

In [2]: setuptools.__version__
Out[2]: '60.8.0'

In [3]: from importlib_metadata import entry_points

In [4]: ep = entry_points().select(group='aiida.calculations', name='core.arithmetic.add')['core.arithmetic.add']

In [5]: type(ep)
Out[5]: importlib_metadata.EntryPoint

In [6]: str(ep)
Out[6]: "EntryPoint(name='core.arithmetic.add', value='aiida.calculations.arithmetic.add:ArithmeticAddCalculation', group='aiida.calculations')"

Behavior of setuptools>=60.9.0

Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import setuptools

In [2]: setuptools.__version__
Out[2]: '60.9.1'

In [3]: from importlib_metadata import entry_points

In [4]: ep = entry_points().select(group='aiida.calculations', name='core.arithmetic.add')['core.arithmetic.add']

In [5]: type(ep)
Out[5]: setuptools._vendor.importlib_metadata.EntryPoint

In [6]: str(ep)
Out[6]: "EntryPoint(name='core.arithmetic.add', value='aiida.calculations.arithmetic.add:ArithmeticAddCalculation', group='aiida.calculations')"

Note how the type of the return value of entry_points().select has changed.

Metadata

Metadata

Assignees

Labels

Needs DiscussionIssues where the implementation still needs to be discussed.bug

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions