On Thu, Dec 6, 2012 at 6:33 AM, Donald Stufft <span dir="ltr"><<a href="mailto:donald.stufft@gmail.com" target="_blank">donald.stufft@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
                <div><span style="color:rgb(160,160,168)">On Thursday, December 6, 2012 at 6:28 AM, Vinay Sajip wrote:</span></div>
                </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span><div><div><div class="im"><div>Donald Stufft <donald.stufft <at> <a href="http://gmail.com" target="_blank">gmail.com</a>> writes:</div><div><br></div></div><div class="im"><div>Never mind the "Obsoletes" information - even the more useful "Requires-Dist"</div>
<div>information is not exposed via PyPI, even though it appears to be stored in the</div><div>database. (Or if it is, please point me to where - I must have missed it.)</div></div></div></div></span></blockquote><div>Requires-Dist doesn't exist for more than a handful of packages. But PyPI exposes</div>
<div>it via the XMLRPC API, possibly the JSON api as well. </div><div class="im"><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px"><span><div><div><div><br></div><div>
Even if this were to be made available, it's presumably obtained from PKG-INFO.</div><div>As I understand, this data is not considered reliable - for example, pip runs</div><div>egg_info on downloaded packages to get updated information when determining</div>
<div>dependencies to be downloaded. If the Requires-Dist info in PKG-INFO can't be</div><div>relied on, surely less critical information such as Obsoletes can't be relied on,</div><div>either?</div></div></div></span></blockquote>
</div><div>pip runs egg_info because setuptools does not write out to PKG-INFO what</div><div>the dependencies are (it does write it out to a different text file though). But IIRC</div><div>that text file is not guaranteed to exist in the distribution. There's also the</div>
<div>history where pip was trying to preserve as much backwards compat with</div><div>easy_install as it could, and if you used the file that egg_info writes out</div><div>then you'll only get the requirements for the system that the distribution was</div>
<div>packaged on. Any if statements that affect the dependencies won't be</div><div>in effect.</div></blockquote><div><br></div><div>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.</div>
<div><br></div><div>I will probably add the unambiguous Conflicts: tag "uninstall this other package if I am installed".</div><div><br></div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div>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:</div>
<div><pre class="" style="padding:10px;font-size:14px;background-color:rgb(224,224,255);color:rgb(0,0,0);line-height:17.816667556762695px">Requires-Dist: pywin32 (>1.0); sys.platform == 'win32'</pre></div><div>
<br></div><div>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.</div>
</div></div>