distutils setup - changing the location in site-packages

Discussion in 'Python' started by imageguy, Feb 21, 2008.

  1. imageguy

    imageguy Guest

    I am hoping if someone can set me straight.

    I have created a setup script for a module, however, when running the
    install on my own machine, I would like to place the module in a
    specific site-packages directory/package.


    So if I start with a module in

    ..\dev\mygreatmodule.py

    I want to end up with;

    ..\lib\site-packages\mytools\mygreatmodule.py.

    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 = "",
    py_modules = ["exceptionhandler"]
    )

    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.

    Any guidance/suggestions would be appreciated.
     
    imageguy, Feb 21, 2008
    #1
    1. Advertising

  2. imageguy

    Guest

    On Feb 21, 9:33 am, imageguy <> 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 = "",
    >   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.
     
    , Feb 21, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bengt Richter
    Replies:
    1
    Views:
    329
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Oct 28, 2004
  2. Philippe C. Martin
    Replies:
    1
    Views:
    330
    vincent wehren
    Jan 18, 2005
  3. Philippe C. Martin
    Replies:
    1
    Views:
    320
    David Fraser
    Jan 19, 2005
  4. andybak
    Replies:
    3
    Views:
    391
  5. Skip Montanaro
    Replies:
    0
    Views:
    137
    Skip Montanaro
    Feb 6, 2013
Loading...

Share This Page