From 013ca172c996bf90f42f54c1f7ae9c2e9639abbd Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sat, 19 Sep 2020 13:33:52 +0000 Subject: More easy_install.ScriptWriter.get_header() Setuptools 12.0 deprecated easy_install.get_script_header() when it was released five years ago, and if called with PYTHONWARNINGS=error raises a deprecation exception. Switch to the preferred class method, but keep the original call as a fallback since it won't work on older Setuptools versions (such as the 3.3 shipped with Ubuntu Trusty). This continues 9a219f9a4f47243123d50d30938506bcc792e55d to remove a second call for the same deprecated function. Change-Id: I365075c2cff88283f92298ce2f5e53d263dc7f4b --- pbr/packaging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pbr/packaging.py b/pbr/packaging.py index 90b9933..ae07796 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -433,7 +433,11 @@ def generate_script(group, entry_point, header, template): def override_get_script_args( dist, executable=os.path.normpath(sys.executable)): """Override entrypoints console_script.""" - header = easy_install.get_script_header("", executable) + # get_script_header() is deprecated since Setuptools 12.0 + try: + header = easy_install.ScriptWriter.get_header("", executable) + except AttributeError: + header = easy_install.get_script_header("", executable) for group, template in ENTRY_POINTS_MAP.items(): for name, ep in dist.get_entry_map(group).items(): yield (name, generate_script(group, ep, header, template)) -- cgit v1.2.1