automatically setting platform-dependent location for Distutils "install-scripts"?

J

jomorcsi

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:
xyzScript.py -- 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 "xyzScript.py" part is installed

Now, I have created a Distutils-based "setup.py" 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=['xyzScript.py'])

.... 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
"xyzScript.py" 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 "os.name" 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
Distutils.
Indeed, I have already done something similar by overriding
"distutils.command.build_scripts"
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!
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top