pypa / pypa/setuptools

[BUG] Vendoring of `importlib_metadata` is shadowing actual package

Open
#3,113 4 comments 1 reaction 1 assignee View on GitHub

@jaraco is already working on this.

Since Feb 16, 2022.

bug Needs Discussion
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.