From b5e40f31208ad23288172bd2b7c2a556244c858f Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 11:46:22 +0100 Subject: [PATCH 1/3] Avoid iterating over entry-points while an empty .egg-info exists in sys.path --- setuptools/command/egg_info.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 280eb5e807..f4d3a2a57e 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -293,13 +293,17 @@ def delete_file(self, filename): os.unlink(filename) def run(self): + # Pre-load to avoid iterating over entry-points while an empty .egg-info + # exists in sys.path. See pypa/pyproject-hooks#206 + writers = list(metadata.entry_points(group='egg_info.writers')) + self.mkpath(self.egg_info) try: os.utime(self.egg_info, None) except OSError as e: msg = f"Cannot update time stamp of directory '{self.egg_info}'" raise distutils.errors.DistutilsFileError(msg) from e - for ep in metadata.entry_points(group='egg_info.writers'): + for ep in writers: writer = ep.load() writer(self, ep.name, os.path.join(self.egg_info, ep.name)) From fa66840443ae2b3bb0a3721879b55c57816fb7ba Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 11:49:38 +0100 Subject: [PATCH 2/3] Remove workaround --- .github/workflows/main.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c765a6bdd..f90a4607b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -100,7 +100,7 @@ jobs: run: | rm -rf dist # workaround for pypa/setuptools#4333 - pipx run --pip-args 'pyproject-hooks<1.1' build + pipx run --pip-args 'pyproject-hooks!=1.1' build echo "PRE_BUILT_SETUPTOOLS_SDIST=$(ls dist/*.tar.gz)" >> $GITHUB_ENV echo "PRE_BUILT_SETUPTOOLS_WHEEL=$(ls dist/*.whl)" >> $GITHUB_ENV rm -rf setuptools.egg-info # Avoid interfering with the other tests diff --git a/pyproject.toml b/pyproject.toml index b9b6d441db..7c6cf36cbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ test = [ "pytest-subprocess", # workaround for pypa/pyproject-hooks#206 - "pyproject-hooks<1.1", # TODO: fix problem with egg-info, see #4670 + "pyproject-hooks!=1.1", "jaraco.test", ] From 28677ae4e4d1d6f5a4267be6df5bdbb024d89d20 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 16:42:40 +0100 Subject: [PATCH 3/3] Add news fragment --- newsfragments/4680.bugfix.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 newsfragments/4680.bugfix.rst diff --git a/newsfragments/4680.bugfix.rst b/newsfragments/4680.bugfix.rst new file mode 100644 index 0000000000..7f5fd0aade --- /dev/null +++ b/newsfragments/4680.bugfix.rst @@ -0,0 +1,4 @@ +Changed ``egg_info`` command to avoid adding an empty ``.egg-info`` while +iterating over entry-points is available in ``sys.path``. +This avoids triggering integration problems with ``importlib.metadata``/``importlib_metadata`` +(reference: pypa/pyproject-hooks#206).