Why is an egg-info file created when I'm using

2019-08-05 08:53发布

问题:

Below is my setup.py. I don't use anything from setuptools in my code and my project has no external dependencies

#!/usr/bin/env python

from distutils.core import setup

setup(name='dots',
        ...
        packages=['dots','dots.configs','dots.management','dots.utils','dots.test'],
        scripts=['dots/dots.py']
        )

When I run python setup.py install, I get the following

running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /Users/kevinlin/.virtualenvs/p-dots/bin/dots.py to 755
running install_egg_info                                                                                <- why?
Removing /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots-0.1-py2.7.egg-info
Writing /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots-0.1-py2.7.egg-info
(p-dots)Kevins-MacBook-Pro-2% python setup.py install
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /Users/kevinlin/.virtualenvs/p-dots/bin/dots.py to 755
running install_egg_info
Removing /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots-0.1-py2.7.egg-info
Writing /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots-0.1-py2.7.egg-info

I notice that an .egg-info file is installed

ls -dl /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots*
drwxr-xr-x  10 kevinlin  staff  340 May  4 11:36 /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots
-rw-r--r--   1 kevinlin  staff  205 May  4 11:36 /Users/kevinlin/.virtualenvs/p-dots/lib/python2.7/site-packages/dots-0.1-py2.7.egg-info

Why?

回答1:

There was discussion about adding setuptools to the stdlib for Python 2.5, and then about adding only pkg_resource (one part of setuptools). Various reasons made that not happen. The core devs recognized that setuptools was an important third-party tool, and accepted a change to make projects installed with a pure-distutils setup.py write this egg-info file, to enable setuptools and tools built on top of it to know that these projects are already installed.

Changeset: http://hg.python.org/cpython/rev/93344da76acd

Ticket: http://bugs.python.org/issue1459476

(I haven’t checked the dates of the 2.5 discussions about setuptools, so my first sentences may be wrong. The rationale is still valid, see the ticket.)