Skip to content

Commit

Permalink
In Distribution.finalize_options, suppress known removed entry points…
Browse files Browse the repository at this point in the history
… for a year to avoid issues with older Setuptools. Fixes #2765.
  • Loading branch information
jaraco committed Sep 6, 2021
1 parent 47b7246 commit 2a5fa49
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/2765.patch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In Distribution.finalize_options, suppress known removed entry points for a year to avoid issues with older Setuptools.
27 changes: 25 additions & 2 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import re
import os
import datetime
import warnings
import numbers
import distutils.log
Expand Down Expand Up @@ -817,10 +818,32 @@ def finalize_options(self):
def by_order(hook):
return getattr(hook, 'order', 0)

eps = map(lambda e: e.load(), pkg_resources.iter_entry_points(group))
for ep in sorted(eps, key=by_order):
defined = pkg_resources.iter_entry_points(group)
filtered = self._suppress_removed_finalization_eps(defined)
loaded = map(lambda e: e.load(), filtered)
for ep in sorted(loaded, key=by_order):
ep(self)

@staticmethod
def _suppress_removed_finalization_eps(defined):
"""
When removing an entry point, if metadata is loaded
from an older version of Setuptools, that removed
entry point will attempt to be loaded and will fail.
See #2765 for more details. Remove these known
removed entry points for a year to limit the
disruption.
"""
removed = {
'2to3_doctests': datetime.date(2021, 9, 5),
}
duration = datetime.timedelta(days=365)
today = datetime.date.today()

def suppress(ep):
return ep.name in removed and today - removed[ep.name] < duration
return itertools.filterfalse(suppress, defined)

def _finalize_setup_keywords(self):
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
value = getattr(self, ep.name, None)
Expand Down

0 comments on commit 2a5fa49

Please sign in to comment.