strange ~150ms startup penalty using python setuptools

Viewed 188

I've been having a weird 150ms startup penalty using python's setuptools, I've constructed a minimal test case and the problem still exists there:

My project layout for this minimal case is:

- setup.py
- setuptest
- - __init__.py
- - __main__.py

The setup.py file contains:

from setuptools import setup

setup(
    name         = 'setuptest',
    version      = '0.1',
    packages     = ['setuptest'],

    entry_points = {
        'console_scripts' : ['setuptest = setuptest.__main__:main']
        } ,
    )

The __main__.py file contains simply:

#!/usr/bin/env python2

def main ():
    print "hai"

if __name__ == '__main__':
    main()

Doing this within the project root:

 —— — time python2 setuptest
hai

real    0m0.021s
user    0m0.017s
sys     0m0.004s

Gives me 21 ms total script execution, however, after running sudo python2 setup.py install and doing:

 —— — time setuptest 
hai

real    0m0.158s
user    0m0.144s
sys     0m0.012s
 —— — 

Gives me 158ms. This +150s startup delay time is consistent and happens across the board when I use setuptools but does not happen with things I installed through the package manager or manually install someone else's project, this leaves me to think I'm obviously doing something very wrongly.

3 Answers
Related