aboutsummaryrefslogtreecommitdiffstats
path: root/pythoneggs.py
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@gmail.com>2015-10-20 23:25:36 +0000
committerPascal Terjan <pterjan@gmail.com>2015-10-20 23:25:36 +0000
commitb77d47f90289413e20f295b93ae8c51012f53e3d (patch)
treeecc4dbf79679445fe2918680630bbfddf6c7db32 /pythoneggs.py
parenta51017344e6ff730f1bcfec3a9089f49ad80de48 (diff)
downloadrpm-setup-b77d47f90289413e20f295b93ae8c51012f53e3d.tar
rpm-setup-b77d47f90289413e20f295b93ae8c51012f53e3d.tar.gz
rpm-setup-b77d47f90289413e20f295b93ae8c51012f53e3d.tar.bz2
rpm-setup-b77d47f90289413e20f295b93ae8c51012f53e3d.tar.xz
rpm-setup-b77d47f90289413e20f295b93ae8c51012f53e3d.zip
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
Diffstat (limited to 'pythoneggs.py')
-rwxr-xr-xpythoneggs.py3
1 files changed, 2 insertions, 1 deletions
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)