From b77d47f90289413e20f295b93ae8c51012f53e3d Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 20 Oct 2015 23:25:36 +0000 Subject: Make python dependencies extraction much faster New style rpm dependency extractors mean that the script is called for each file in the package. This exhibit the slowness of the python one, where most of the time is spent on importing a module which is usually not needed. Running pythoneggs.py --requires on python-setuptools: Before: real 1m43.763s user 1m33.220s sys 0m7.460s After: real 0m18.298s user 0m15.060s sys 0m2.190s --- pythoneggs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pythoneggs.py b/pythoneggs.py index 367aad1..a1c819b 100755 --- a/pythoneggs.py +++ b/pythoneggs.py @@ -12,7 +12,6 @@ from getopt import getopt from os.path import basename, dirname, isdir, sep, splitext from sys import argv, stderr, stdin, version -from pkg_resources import Distribution, FileMetadata, PathMetadata from distutils.sysconfig import get_python_lib @@ -82,6 +81,8 @@ for f in files: parent_name.endswith('.egg-info') or \ parent_name.endswith('.egg-link') if file_match or dir_match: + # This import is very slow, so only do it if needed + from pkg_resources import Distribution, FileMetadata, PathMetadata dist_name = basename(f) if dir_match: path_item = dirname(parent_name) -- cgit v1.2.1