Search code examples
pythonversion-controlegg

egg_info directory in VC?


Do you keep the foo.egg_info directory in version control?

Here an example where it would be nice to have it in VC:

  1. pip install -e foo
  2. Someone else adds a new EntryPoint (pkg_resource)
  3. You update the code and pull the new EntryPoint (file foo.egg-info/entry_points.txt)
  4. The new EntryPoint is available without calling setup.py again

Solution

  • If all that was updated in the package was the addition of an entry point, that'd be an irresponsible release; if any feature changes in a package, you need to update the version number. How else will you know that you have the right feature set installed?

    If you are using eggs from a VCS, then pip already takes care of updating the egg info for you. Just run pip install -e foo again; it'll update the package and re-generate the egg info for you:

    $ bin/pip install -e git+https://github.com/mjpieters/setuptools_subversion.git#egg=setuptools_subversion
    Obtaining setuptools-subversion from git+https://github.com/mjpieters/setuptools_subversion.git#egg=setuptools_subversion
      Cloning https://github.com/mjpieters/setuptools_subversion.git to /tmp/pip-e/src/setuptools-subversion
      Running setup.py egg_info for package setuptools-subversion
    
    Installing collected packages: setuptools-subversion
      Running setup.py develop for setuptools-subversion
    
        Creating /private/tmp/pip-e/lib/python2.7/site-packages/setuptools-subversion.egg-link (link to .)
        Adding setuptools-subversion 3.2 to easy-install.pth file
    
        Installed /private/tmp/pip-e/src/setuptools-subversion
    Successfully installed setuptools-subversion
    Cleaning up...
    $ bin/pip install -e git+https://github.com/mjpieters/setuptools_subversion.git#egg=setuptools_subversion
    Obtaining setuptools-subversion from git+https://github.com/mjpieters/setuptools_subversion.git#egg=setuptools_subversion
      Updating /tmp/pip-e/src/setuptools-subversion clone
      Running setup.py egg_info for package setuptools-subversion
    
    Installing collected packages: setuptools-subversion
      Running setup.py develop for setuptools-subversion
    
        Creating /private/tmp/pip-e/lib/python2.7/site-packages/setuptools-subversion.egg-link (link to .)
        setuptools-subversion 3.2 is already the active version in easy-install.pth
    
        Installed /private/tmp/pip-e/src/setuptools-subversion
    Successfully installed setuptools-subversion
    Cleaning up...
    

    Note the second invokation; instead of 'cloning', the second run states pip is 'updating' the VCS clone, after which setup.py egg_info is run again.

    The egg info metadata is entirely generated from source; only commit the source to the VCS and leave the egg info out of it entirely. That way you can still generate platform-specific dependencies as well, for example.