blob: 7e931c845c868cbebead1e18002e64dd8953b75c [file] [log] [blame]
From aae8cd3de3f289cea3db01212579913c925191e8 Mon Sep 17 00:00:00 2001
From: Lauri Tirkkonen <lauri.tirkkonen.ext@nokia.com>
Date: Thu, 26 Mar 2020 14:24:25 +0000
Subject: [PATCH] ScriptWriter: create more efficient /usr/bin wrappers
Upstream setuptools writes scripts to /usr/bin that do insanely much
stuff at runtime. https://github.com/pypa/setuptools/issues/510
Since the script entry points are already known at build time, we can
just write those directly into the /usr/bin wrapper, avoiding the
expensive 'pkg_resources' import at runtime. The idea is from
https://github.com/ninjaaron/fast-entry_points but patched directly into
the native build of setuptools here, so that all Python modules under
bitbake automatically use it without needing additional build time
dependencies.
Upstream-Status: Pending
Signed-off-by: Lauri Tirkkonen <lauri.tirkkonen.ext@nokia.com>
Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
---
setuptools/command/easy_install.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 8fba7b41..03a72714 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -2023,17 +2023,12 @@ class ScriptWriter(object):
"""
template = textwrap.dedent(r"""
- # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
- __requires__ = %(spec)r
- import re
import sys
- from pkg_resources import load_entry_point
+
+ from %(module)s import %(ep0)s
if __name__ == '__main__':
- sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
- sys.exit(
- load_entry_point(%(spec)r, %(group)r, %(name)r)()
- )
+ sys.exit(%(entrypoint)s())
""").lstrip()
command_spec_class = CommandSpec
@@ -2068,6 +2063,9 @@ class ScriptWriter(object):
for type_ in 'console', 'gui':
group = type_ + '_scripts'
for name, ep in dist.get_entry_map(group).items():
+ module = ep.module_name
+ ep0 = ep.attrs[0]
+ entrypoint = '.'.join(ep.attrs)
cls._ensure_safe_name(name)
script_text = cls.template % locals()
args = cls._get_script_args(type_, name, header, script_text)
--
2.24.1