Support entry point patching on setuptools < 12
In patch 789888 we began relying on EntryPoint.resolve(), which only exists in setuptools >= 12, breaking support for setuptools < 12. This includes the default virtualenv installations from may LTS distributions. As ep.load with arguments is deprecated we will attempt to use ep.resolve if it exists and fall back to ep.load(false) if it does not. setuptools 11 is the odd release out, as this was when load with arguments was deprecated, suggesting the use of ep._load. We will continue to use ep.load(False) here. Change-Id: I272f76fef7e447378697a3980372191f4ffe1a2f
This commit is contained in:
10
pbr/util.py
10
pbr/util.py
@@ -556,7 +556,15 @@ def wrap_commands(kwargs):
|
||||
# with this here.
|
||||
for ep in pkg_resources.iter_entry_points('distutils.commands'):
|
||||
if ep.name not in dist.cmdclass:
|
||||
cmdclass = ep.resolve()
|
||||
if hasattr(ep, 'resolve'):
|
||||
cmdclass = ep.resolve()
|
||||
else:
|
||||
# Old setuptools does not have ep.resolve, and load with
|
||||
# arguments is depricated in 11+. Use resolve, 12+, if we
|
||||
# can, otherwise fall back to load.
|
||||
# Setuptools 11 will throw a deprication warning, as it
|
||||
# uses _load instead of resolve.
|
||||
cmdclass = ep.load(False)
|
||||
dist.cmdclass[ep.name] = cmdclass
|
||||
|
||||
for cmd, _ in dist.get_command_list():
|
||||
|
||||
Reference in New Issue
Block a user