From 4d9504e775d89f06b3e7199e076e62ff4fd9d1d2 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 7 Sep 2018 12:14:46 -0700 Subject: [PATCH] Remove runtime usage of pkg_resources. This should provide a startup time speed boost at the expense of making it harder to get ansible to use newer versions of packages than are provided by the platform. --- bin/ansible | 10 +--------- bin/ansible-connection | 4 ---- changelogs/fragments/drop-pkg_resources.yaml | 8 ++++++++ requirements.txt | 1 - 4 files changed, 9 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/drop-pkg_resources.yaml diff --git a/bin/ansible b/bin/ansible index cc4bfd7a694..cd83e9a4131 100755 --- a/bin/ansible +++ b/bin/ansible @@ -22,15 +22,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type __requires__ = ['ansible'] -try: - import pkg_resources -except Exception: - # Use pkg_resources to find the correct versions of libraries and set - # sys.path appropriately when there are multiversion installs. But we - # have code that better expresses the errors in the places where the code - # is actually used (the deps are optional for many code paths) so we don't - # want to fail here. - pass + import os import shutil diff --git a/bin/ansible-connection b/bin/ansible-connection index ac378a4d872..a06adcfc3b7 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -6,10 +6,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type __requires__ = ['ansible'] -try: - import pkg_resources -except Exception: - pass import fcntl import hashlib diff --git a/changelogs/fragments/drop-pkg_resources.yaml b/changelogs/fragments/drop-pkg_resources.yaml new file mode 100644 index 00000000000..dadb13594e9 --- /dev/null +++ b/changelogs/fragments/drop-pkg_resources.yaml @@ -0,0 +1,8 @@ +--- +minor_changes: + - Drop the use of pkg_resources. Importing pkg_resources was the costliest + part of startup time for Ansible. pkg_resources was used so that platforms + with old versions of PyCrypto and Jinja2 could use parallel installed, + updated versions. Since we no longer support Python-2.6 on the controller + side, we no longer have to support parallel installation to work around + those old stacks. diff --git a/requirements.txt b/requirements.txt index 09ba9fc6f06..ac904c49b8e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,3 @@ jinja2 PyYAML paramiko cryptography -setuptools