[Distutils] setuptools bug, inconsistent replacement of eggs when installing from file:// urls.

Fadhley Salim Fadhley.Salim at uk.calyon.com
Fri Mar 27 19:10:23 CET 2009

I think I've found a bug in the way that setuptools selects whether an
egg specified by file:// url should be installed over an existing
(identical) egg:
To re-create the fault:
* Install the egg of your choice.
* make two local "egg repositories", one with a very long path (e.g.
c:/a/) and one with a very long path
* In each of the egg repositories place a copy of the egg you just
installed, along with an HTML file containing a link to that egg... just
it's filename.
* Try to easy_install the egg with the options "-mv" and set "-f" to
either one of the repositories
When you select a short path for the repository you will notice that the
egg in your site_packages folder is always replaced, you see something
like this:
When you select a very long path for the repository you will not see
this message, this is because easy_install leaves the egg unmodified.
I've found out why this happens: The pkg_resources.Environment uses a
hash-tuple to work out the order in which to consider packages to
install. If you are trying to install two identical eggs, the 4th
element of the tuple -len(self.location or '') becomes significant...
longer URLs get preference to shorter URLs. 
That on it's own might not seem too bad, but consider the the 2nd value
of the hash-tuple (precedence) is given an identical value of 3 both for
a package which is already installed in pkg_resources and a package
which can already be downloaded from a file:// link. I think a better
default behaviour would be for it to give stuff that is already
installed a higher precedence than stuff which could potentially be
Hope all of this makes sense!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20090327/3f77801d/attachment.htm>
-------------- next part --------------
This email does not create a legal relationship between any member of the 
Cr=E9dit Agricole group and the recipient or constitute investment advice. 
The content of this email should not be copied or disclosed (in whole or 
part) to any other person. It may contain information which is 
confidential, privileged or otherwise protected from disclosure. If you 
are not the intended recipient, you should notify us and delete it from 
your system. Emails may be monitored, are not secure and may be amended, 
destroyed or contain viruses and in communicating with us such conditions 
are accepted. Any content which does not relate to business matters is not 
endorsed by us.

Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des
Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire
in France and subject to limited regulation by the Financial Services Authority.
Details about the extent of our regulation by the Financial Services Authority
are available from us on request. Calyon is incorporated in France with limited
liability and registered in England & Wales. Registration number: FC008194.
Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA.
This message and/or any  attachments is intended for the sole use of its addressee.
If you are not the addressee, please immediately notify the sender and then destroy the message.
As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB.
All rights reserved.

Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire.
Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite.
Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu.
Tous droits r?serv?s.

More information about the Distutils-SIG mailing list