Can someone explain how egg-info directories are tied to their respective modules? For example, I have the following:


I’m assuming the egg-info directory is to make the corresponding module visible to setuptools (easy_install), right? If so, how does setuptools tie the egg-info directory to the module directory?

Assuming that I’m on the right track, and for the sake of example… If I wanted to make an existing package of mine visible to setuptools, could I just symlink the module directory and the egg-info directory to the site-packages directory? I would have just tried this myself, but I’m not sure how to test if the package is visible to setuptools. Bonus points if you can also tell me how to test this 🙂

The main reason I’m trying to understand all this is because I would like to symlink some of my modules into site-packages so that I can make changes to them and have the changes visible to the scripts that use them without having to reinstall the egg from PyPI after each change.

The .egg-info directories get only created if –single-version-externally-managed was used to install the egg. “Normally”, installing an egg would create a single directory (or zip file), containing both the code and the metadata.

pkg_resources (which is the library that reads the metadata) has a function require which can be used to request a specific version of the package. For “old-style”, regular imports, easy_install hacks a .pth file to get the egg directory onto sys.path. For –single-version-externally-managed, this hacking is not necessary, because there will only be a single version installed (by the system’s pacakging infrastructure, e.g. rpm or dpkg). The egg-info is still included, for applications that use require (or any of the other pkg_resources binding mechanisms).

If you want to install a package by hard-linking, I recommend to use “ develop”. This is a command from setuptools which doesn’t actually install the egg, but makes it available site-wide. To do so, it creates an egg-link file so that pkg_resources can find it, and it manipulates a .pth file, so that regular import can find it.