Skip to content

Commit b5e40f3

Browse files
committed
Avoid iterating over entry-points while an empty .egg-info exists in sys.path
1 parent f8a2825 commit b5e40f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

setuptools/command/egg_info.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,17 @@ def delete_file(self, filename):
293293
os.unlink(filename)
294294

295295
def run(self):
296+
# Pre-load to avoid iterating over entry-points while an empty .egg-info
297+
# exists in sys.path. See pypa/pyproject-hooks#206
298+
writers = list(metadata.entry_points(group='egg_info.writers'))
299+
296300
self.mkpath(self.egg_info)
297301
try:
298302
os.utime(self.egg_info, None)
299303
except OSError as e:
300304
msg = f"Cannot update time stamp of directory '{self.egg_info}'"
301305
raise distutils.errors.DistutilsFileError(msg) from e
302-
for ep in metadata.entry_points(group='egg_info.writers'):
306+
for ep in writers:
303307
writer = ep.load()
304308
writer(self, ep.name, os.path.join(self.egg_info, ep.name))
305309

0 commit comments

Comments
 (0)