pkg_resources module causes a delay of between 0 and many seconds every time `bst` starts up
We currently use the pkg_resources module from setuptools to do 3 things:
- operate the
/usr/bin/bst
and/usr/bin/bst-artifact-receive
hooks generated by setuptools - report the BuildStream version number
- discover plugins installed with Pip
Importing pkg_resources causes a scan of every installed Python module, which can take be a significant slowdown. On my system it typically takes 0.3 seconds to run python3 -c 'import pkg_resources'
; running bst --help
typically takes 0.5 seconds, of which more than half is spent in the pkg_resources module. The upstream bug report shows that pkg_resources can take 2 seconds or more to import in some scenarios.
Upstream bug: https://github.com/pypa/setuptools/issues/510
Edited by Sam Thursfield