title: Execute an installed Python package as a script?
body: <p>Is there a way to enable a package to be executed as a script? For example:</p>
  
  <pre><code>[~]# easy_install /path/to/foo.egg
  ...
  [~]# python -m foo --name World
  Hello World
  </code></pre>
  
  <p>I've tried creating a <code>__main__.py</code> file inside my package but it's not being executed (I'm using Python 2.6). The following error is raised: </p>
  
  <pre><code>foo is a package and cannot be directly executed
  </code></pre>
  
  <p>The structure of my package is as follows:</p>
  
  <pre><code>foo/
    setup.py
    foo/
      __init__.py
      __main__.py
  </code></pre>
  
  <p>Running <code>python -m foo.__main__ --name World</code> works as expected, but I would prefer the former way of execution. Is this possible?</p>