title: Create a python executable using setuptools
body: <p>I have a small python application that I would like to make into a downloadable / installable executable for UNIX-like systems.  I am under the impression that setuptools would be the best way to make this happen but somehow this doesn't seem to be a common task.</p>
  
  <p>My directory structure looks like this:</p>
  
  <pre><code>myappname/
  |-- setup.py
  |-- myappname/
  |   |-- __init__.py
  |   |-- myappname.py
  |   |-- src/
  |      |-- __init__.py
  |      |-- mainclassfile.py
  |      |-- morepython/
  |         |-- __init__.py
  |         |-- extrapython1.py
  |         |-- extrapython2.py
  </code></pre>
  
  <p>The file which contains <code>if __name__ == "__main__":</code>  is myappname.py.  This file has a line at the top, <code>import src.mainclassfile</code>.</p>
  
  <p><strong>When this is downloaded, I would like for a user to be able to do something like</strong>:</p>
  
  <pre><code>$ python setup.py build
  $ python setup.py install
  </code></pre>
  
  <p><strong>And then it will be an installed executable</strong> which they can invoke from anywhere on the command line with:</p>
  
  <pre><code>$ myappname arg1 arg2
  </code></pre>
  
  <p>The important parts of my setup.py are like:</p>
  
  <pre><code>from setuptools import setup, find_packages
  setup(
    name='code2flow',
    scripts=['myappname/myappname.py'],
    package_dir={'myappname': 'myappname'},
    packages=find_packages(),
    )
  </code></pre>
  
  <h2>Current state</h2>
  
  <p>By running:</p>
  
  <pre><code>$ sudo python setup.py install
  </code></pre>
  
  <p>And then in a new shell:</p>
  
  <pre><code>$ myapp.py
  </code></pre>
  
  <p>I am getting a <code>No module named</code> error</p>