organizing a Python application
<p>I have a Python application, and I have a question about packaging that isn't really a distutils question, but rather a question of how to organize and set up the application so it's easily used from the command line.</p>

<p>Assume the application contains one package, and assume for the moment that I don't necessarily want to make it a distutils package (although I could be dissuaded.)</p>

<p>The program itself as an SNMP subagent to be run by Net-SNMP using pass_persist.  This isn't particularly important to the question, it just means the program overall is exec'd, and reads stdin with responses on stdout.</p>

<p>Further assume the agent is structured in the more or less canonical Python fashion</p>

<pre><code>  agent
      __init__.py
      main.py
      &lt;other modules at the same level&gt;
</code></pre>

<p><code>main.py</code> is a simple program something like</p>

<pre><code>#!/usr/bin/env python
import sys
def main(argv):
    &lt;initialize the environment, input output, logging and so on&gt;
    while &lt;not done&gt;:
         &lt;process an input&gt;
    &lt;clean up and terminate&gt;

if __name__ == '__main__':
    main(sys.argv)
</code></pre>

<p>There seem to be just a few ways this can be organized to be run:</p>

<p>Put the package somewhere in site-packages and have a top-level program in the PATH like</p>

<pre><code>#!/usr/bin/env python
from agent import main
main(sys.argv)
</code></pre>

<p>Put the package directory somewhere and run it by using</p>

<pre><code>/path/to/directory/agent/main.py
</code></pre>

<p>(with the bumpo version being to put the agent directory in the path somewhere so you can just run <code>main.py</code>)</p>

<p>or some third, more Pythonic and cool, method that lets me install the code and put something into the path directly that I don't know.</p>

<p>Googling hasn't helped much, I suspect this is one of those "too dumb to answer" questions.  I am, unfortunately, too dumb to know that.</p>
