(original) (raw)
On Thu, Dec 6, 2012 at 6:33 AM, Donald Stufft <donald.stufft@gmail.com> wrote:
On Thursday, December 6, 2012 at 6:28 AM, Vinay Sajip wrote:Donald Stufft gmail.com> writes:Never mind the "Obsoletes" information - even the more useful "Requires-Dist"information is not exposed via PyPI, even though it appears to be stored in thedatabase. (Or if it is, please point me to where - I must have missed it.)Requires-Dist doesn't exist for more than a handful of packages. But PyPI exposesit via the XMLRPC API, possibly the JSON api as well.�Even if this were to be made available, it's presumably obtained from PKG-INFO.As I understand, this data is not considered reliable - for example, pip runsegg\_info on downloaded packages to get updated information when determiningdependencies to be downloaded. If the Requires-Dist info in PKG-INFO can't berelied on, surely less critical information such as Obsoletes can't be relied on,either?pip runs egg\_info because setuptools does not write out to PKG-INFO whatthe dependencies are (it does write it out to a different text file though). But IIRCthat text file is not guaranteed to exist in the distribution. There's also thehistory where pip was trying to preserve as much backwards compat witheasy\_install as it could, and if you used the file that egg\_info writes outthen you'll only get the requirements for the system that the distribution waspackaged on. Any if statements that affect the dependencies won't bein effect.
It will be Obsoleted-By:. The "drop in replacement" requirement will be removed. The package manager will say "you are using these obsolete packages; check out these non-obsolete ones" but will not automatically pull the replacement without a Requires tag.
I will probably add the unambiguous Conflicts: tag "uninstall this other package if I am installed".
Many packages (IIRC more than half) have the pre-Metadata-1.2 equivalent of Requires-Dist: which is the very easy to parse requires.txt. This information is not reliable because it could depend on conditions in setup.py. Someone should write a setup.py compiler that determines whether a package's requirements are conditional or not.
Environment markers (limited Python expressions at the end of Requires-Dist lines) attempt to make Requires-Dist reliable. You can execute them safely in your environment to determine whether �a requirement is right for you:
Requires-Dist: pywin32 (>1.0); sys.platform == 'win32'
The wheel implementation makes sure all the metadata (the .dist-info directory) is at the end of the .zip archive. It's possible to read the metadata with a single HTTP partial request for the end of the archive without downloading the entire archive.