distutils setup - changing the location in site-packages

I

imageguy

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 = "(e-mail address removed)",
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.
 
J

james.pye

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 = "(e-mail address removed)",
  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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top