title: How should setup.py and requirements.txt be used by app developers?
body: <p>What should an <em>app developer</em> place in <code>setup.py</code> and <code>requirements.txt</code>? Should an <em>app</em> even have a <code>setup.py</code>?</p>
  
  <p>The <a href="https://docs.python.org/2/distutils/setupscript.html" rel="noreferrer">docs</a> seem to only cover the scenario of writing a <em>module</em>. But in an app, how should package and module dependency be encoded? Using both setup.py and requirements.txt?</p>
  
  <p>I've been handed a 2.7.8 project with some questionable coding, and I'm not sure if this <code>setup.py</code> is reasonable. I'm surprised by the amount of boilerplate coding:</p>
  
  <pre><code>#!/usr/bin/env python
  from setuptools import setup, find_packages
  import sys
  
  if sys.argv[1] == 'test':
      import multiprocessing, logging
      from billiard import util
  
  with open('requirements.txt') as f:
      required = f.read().splitlines()
  
  if sys.version_info &lt; (2, 7, 0):
      required.append('importlib')
  
  setup(
      version='0.1',
      name='...',
      description='...',
      author='...',
      author_email='...',
      packages=find_packages(),
      package_data={},
      install_requires=required,
      include_package_data=True,
      tests_require=[
          'billiard',
          'nose==1.3'
      ],
      test_suite='nose.collector'
  )
  </code></pre>
  
  <p>I'm new to Python, but I see some potential problems:</p>
  
  <ul>
  <li>An irrelevant version number which needs to be manually updated.</li>
  <li>The 'test' imports aren't relevant to the project ("multiprocessing"). </li>
  <li>We don't run tests by executing setup.py; we execute the <code>nosetests</code> command.</li>
  <li><code>install_requires</code> depends on the contents of <code>requirements.txt</code>. But afaik it should be the other way around: <code>requirements.txt</code> needs to be generated based on the <code>install_requires</code> section.</li>
  <li>It seems to check for a python version which the app isn't coded to support.</li>
  </ul>