title: Prevent package from being installed on old Python versions
body: <p>What can we put in a <code>setup.py</code> file to prevent pip from collecting and attempting to install a package when using an unsupported Python version?</p>
  
  <p>For example <a href="https://pypi.python.org/pypi/magicstack/" rel="noreferrer"><code>magicstack</code></a> is a project listed with the trove classifier:</p>
  
  <pre><code>Programming Language :: Python :: 3 :: Only
  </code></pre>
  
  <p>So I expect the following behaviour if <code>pip --version</code> is tied to python 2.7:</p>
  
  <pre><code>$ pip install magicstack
  Collecting magicstack
    Could not find a version that satisfies the requirement magicstack (from versions: )
  No matching distribution found for magicstack
  </code></pre>
  
  <p>But the actual behavior is that pip collects a release, downloads it, attempts to install it, and fails.  There are other Python3-only releases, <a href="https://github.com/dabeaz/curio" rel="noreferrer"><code>curio</code></a> for example, which actually install fine - because the <code>setup.py</code> didn't use anything Python 3 specific - only to fail at import time when some Python 3 only syntax is used.  And I'm sure there are packages which install OK, import OK, and maybe only fail at runtime!  </p>
  
  <p><strong>What is the correct method to specify your supported Python versions in a way that pip will respect?</strong>  I've found a workaround, involving uploading only a wheel file, and refusing to uploading a .tar.gz distribution, but I would be interested to know the correct fix.  </p>
  
  <hr>
  
  <p><em>Edit:</em>  How does pip know <em>not</em> to download the wheel distribution if the Python/os/architecture is not matching?  Does it just use the <a href="https://www.python.org/dev/peps/pep-0427/#file-name-convention" rel="noreferrer">.whl filename convention</a> or is there something more sophisticated than that happening behind the scenes?  Can we somehow give the metadata to a source distribution to make pip do the right thing with .tar.gz uploads?</p>