Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   distutils setup - changing the location in site-packages (http://www.velocityreviews.com/forums/t593255-distutils-setup-changing-the-location-in-site-packages.html)

imageguy 02-21-2008 04:33 PM

distutils setup - changing the location in site-packages
 
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 = "me@mydomain.com",
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.

james.pye@gmail.com 02-21-2008 05:14 PM

Re: distutils setup - changing the location in site-packages
 
On Feb 21, 9:33*am, imageguy <imageguy1...@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...@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.


All times are GMT. The time now is 08:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.