distutils setup - changing the location in site-packages

james.pye at gmail.com james.pye at gmail.com
Thu Feb 21 18:14:52 CET 2008


On Feb 21, 9:33 am, imageguy <imageguy1... at gmail.com> wrote:
> I have the setup script working, however, when I run the install, it
> places the module in the root of site-packages.
>
> The following is the deatils from the script
> setup (
>   name = "mymodule",
>   version = "0.1",
>   description = "My modules special description",
>   author = "me",
>   author_email = "m... at mydomain.com",
>   py_modules = ["exceptionhandler"]
> )

Yeah, you need to specify the module path. ie, ``py_modules =
["mytools.exceptionhandler"]``

However, chances are that you want use ``packages``:

setup (
 ...
 packages = ["mytools"]
)

This should include the ``exceptionhandler`` module in the package.

Additionally, you'll need to structure the project to have a
``mytools`` directory that contains an ``__init__.py`` file(package
initialization module), and the ``exceptionhandler.py`` file:

projectdir/
 |
 |- mytools/
 |    |
 |    |- __init__.py
 |    |- exceptionhandler.py
 |
 |- setup.py
 ...

This can be somewhat undesirable if you're using cvs, as chances are
you'll want to change the package's name at some point in the future.
However, I have found that the annoyance of empty directories
littering the module's tree does not outweigh the annoyance of not
being able to use setuptools' ``develop`` command. Not to mention the
simplicity of just using ``packages``.

> This is for development purposes.  I would like to have a development
> copy of some "tools", but when ready and tested "publish" them to the
> site-packages where they can be included in "production" code.

setuptools' 'develop' command can be handy for this.

Hope this helps.



More information about the Python-list mailing list