Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix issues with distribution location from eggs #629
Please consider the following pull request, which addresses real-world issues (and took a while to debug).
This patch will ignore empty egg directories, which I think is intended.
Thus, when something like pkg_resources.get_distribution('packageName') is called, it returns a distribution based off the OLD empty egg info, which causes issues and/or complete failure.
I'm sure there are many other circumstances that could leave behind an empty egg directory.
This patch causes empty egg-info directories to be skipped.
\2. "Scan for distributions in reverse order, so we find the newest version of a distrubtion (instead of the oldest)" -- fb1867e
Since os.listdir returns (at least on POSIX) directories in lexicographical order, old versions of eggs will be found and associated with a distribution, even when newer versions are present.
This patch searches the reverse of os.listdir, which will find and associate the NEWEST version of a package instead of the OLDEST (for calls like pkg_resources.get_distribution)
If you don't want to apply number 1 (because, I understand that while nothing in practice does generate empty egg directories, the name itself can identify version, etc), this patch in practice usually will result in the same goal, since during upgrades the newer package will be found and the empty ignored anyway. However, this patch alone does not cover downgrades, etc.
Please seriously consider these two patches. I know there are workarounds in the sense of deleting old empty egg directories, but in real-world one often has no control over third-party RPMs etc which by template use the "record" option of setup.py. Also, it could be the case that someone manually installs an old egg on one server, and then an rpm comes along later and installs a newer version, and you have an issue that 1/4 times the application fails because it identifies the wrong egg, etc. All very hard to debug, and in the case of using third-party distributions require things like pruning empty directories through cron, etc. These patches could alleviate these issues, and I think overall harden the setuptools codebase.
Steps to reproduce:
After / Desired:
I apologize for letting this issue linger for so long. After reviewing, the changes seem reasonable. It would be nice if the changes had tests, but I'm not going to insist on that. At the same time, I disavow responsibility if the functionality gets optimized out because it's not protected by tests.
One concern I have is that lexicographic sorting is not the same as package version order. The simple example is that lexicographically,
It would be better to extract and sort by the version. In practice, this
On Fri, Oct 14, 2016 at 1:27 PM, Jason R. Coombs firstname.lastname@example.org