Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > automatically setting platform-dependent location for Distutils "install-scripts"?

Thread Tools

automatically setting platform-dependent location for Distutils "install-scripts"?
Posts: n/a
Hello all,

I am developing a Python-based tool that will be deployed both in a
Windows and in a Linux
environment, and I have a question concerning the use of the Distutils
module to manage the
installation of the tool in a transparent manner.

A bit of background info:
1. (I am using Python version 2.5)
2. Let's assume that the tool is named "xyz"
3. It is internally partitioned into two parts: -- the front-end script that the users actually
invoke, and
xyzPackage -- a package containing the "guts" of the tool
4. Users do not really care where the "xyzPackage" part is installed
and thus by default it will be installed into Python's standard
"site-packages" directory.
5. However, users *do* care where the "" part is installed

Now, I have created a Distutils-based "" script that looks
like this:
from distutils.core import setup

> setup(name='xyz',
> version="1.0",
> # provide other metadata, such as 'description', 'author', 'author_email', 'url', ... etc.
> packages=['xyzPackage'],
> scripts=[''])

.... that takes care of the above concerns, and also accepts a
"setup.cfg" configuration file that
allows the user to control into which directory to install the
"" part, as follows:

> [install]
> install-scripts=C:\xyzScriptDirectory

And thus, here is my problem:

[1] At any given moment, the directory name specified in the above
"setup.cfg" file
can be either a "Windows-style" directory (as is shown above)
or a "Linux-style" directory (say "/opt/xyzScriptDirectory"), but
not both!

[2] I would like to have a *single* "setup.cfg" file that can
nevertheless be used for *both*
Windows and Linux, *without* having to be edited by the user.

For example, it would be really nice if I can have a customized
"setup.cfg" file that looks like:

> [install]
> install-scripts-Windows=C:\xyzScriptDirectory
> install-scripts-Linux=/opt/xyzScriptDirectory

.... and then some part of Distutils can query "" and set the
"real" 'install-scripts' option
to the appropriate one of these two choices.

I assume this can be done by "overriding" and customizing part of
Indeed, I have already done something similar by overriding
to use a customized "copy_scripts()" method.

However, it is not clear to me in what manner I can/should
override "distutils.command.install_scripts" to achieve the effect
that I desire.

Is this at all the way to go, or might there be a totally obvious way
to do this
that I am currently overlooking?

If anyone has similar experience in tweaking Distutils, I would be
most appreciative of any
advice that you can offer.

Thanks in advance!

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you reference VCS location in distutils.core.setup()? Skip Montanaro Python 0 02-06-2013 03:16 PM
distutils, No module named numpy.distutils.fcompiler.conv_template Luis Alberto Zarrabeitia Gomez Python 0 03-30-2009 03:56 PM
distutils setup - changing the location in site-packages imageguy Python 1 02-21-2008 05:14 PM
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
can distutils windows installer invoke another distutils windows installer Python 1 05-11-2006 10:07 PM