Search code examples
pythonsetuptoolsdistutilsegg

top-level package handling with setuptools (or another python egg builder)


I am writing a little python app. I want to be able to easily deploy the app. I know that python 2.6 will allow one to execute an egg directly if there is a main module at the egg's root. I actually have that working.

The one kink is that when I try to use the argparse library, I cannot include the library in the egg without installing it into my source directory (or symlinking in the argparse.py into my source dir) since the argparse module is in the top-level package.

If I install it into a subdirectory called "argparse", I have to import it like "from argparse import argparse" instead of the normal "import argparse".

I would like to be able to specify a site-packages type directory in the egg where I could just install the third party modules/packages. Is there any way to do this with setuptools (or some other egg builder)?

Thanks!


Solution

  • I believe you can create a subdirectory called toplevel and in your entry point do

    import sys
    sys.path.insert(0, './toplevel')
    

    Untested, though.