title: Resolving Python dependencies at installation time in setup.py based on an interpreter version
body: <p>Suppose I have a bunch of requirement files like:</p>
  
  <pre><code>requirements.txt   # common for both 2.x and 3.x
  requirements-2.txt # 2.x
  requirements-3.txt # 3.x
  </code></pre>
  
  <p>and I would like to populate <code>install_requires</code> argument in <code>setup.py</code> file based on the current Python interpreter version. Assume of course that <strong>pip</strong> handles the installation process.</p>
  
  <p><strong>Solution 1:</strong> Of course, I can write a simple function that will read and return correct requirements. In a case with multiple projects this is obviously not acceptable, since I will have to copy the function everywhere.</p>
  
  <p><strong>Solution 2:</strong> Next idea here is to write a simple package that does it for me, but the problem is that it should be available not only at distribution time (like <code>python setup.py sdist</code>), but more importantly, at installation time on one's machine.</p>
  
  <p>I was managed to write a simple module that does the thing, lets call it <code>depmodule</code>. I also  had following <code>setup.py</code>:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from setuptools import setup, find_packages
  
  try:
      from depmodule import find_requirements
  except ImportError:
      # this line is executed when reading setup.py for the first time
      # since depmodule is not installed yet
      find_requirements = lambda: []
  
  setup(
      name='some-package',
      packages=find_packages(),
      # snip...
      platforms='any',
  
      # note that depmodule is listed here as a requirement, so it will be
      # installed before some-package, thus will be available when it comes
      # to running setup.py of some-package
      install_requires=['depmodule'] + find_requirements(),
  )
  </code></pre>
  
  <p>When it comes to <code>pip install some-package</code> it <strong>actually resolves dependencies correctly</strong>, but they are not picked up by pip, so it only installs: <code>depmodule some-package</code> (in that order) instead of <code>depmodule dep1 dep2 ... some-package</code>.</p>
  
  <p>I tried to use <code>setup_requires</code> argument but with no luck. The dependency was downloaded, but I could not access it, since it was an egg package (not extracted). </p>
  
  <p>Is there any way I can overcome this issue? Are there any alternatives (other approaches) that could help with this?</p>
  
  <p>Thanks!</p>