[Distutils] Installing scripts

Mark Hammond mhammond at skippinet.com.au
Thu Jul 1 23:56:00 EDT 2004


[Fred]
>  > How about something like:
>  >
>  > strip_extensions = {"posix": "txt py pyw", "darwin": "txt" }
>  >
>  > Where strip_extensions is a dictionary, keyed by the
> platform name (either
>  > sys.platform or os.name - whatever makes sense.  The value
> is the list of
>  > extensions that should be stripped.
>
> So how do you spell "I want the extension stripped from this
> one file on one
> platform, and that's it."?

I guess we change the strip_extensions to a complete filespec - '*.txt',
'foo.txt', etc

> I'm also confused by your
> inclusion of "txt";
> does this apply to all file copies, just scripts, or some magically
> determined set of file copies?

I was replying to your original '--strip-extensions' idea, so it would apply
to whatever files you had in mind originally <wink>.

> That would allow something like this in setup.py:
>
> from distutils.core import setup, Script
>
> setup(name='Some Python Utilities',
>       packages=['mytools'],
>       scripts=[Script('bin/dostuff.py', strip_extension=1),
>                Script('bin/morestuff.py', strip_extension=1, sbin=1),
>                ],
>       )
>
> Additional keywords might be used to mark a script to be
> installed only on
> certain platforms.  This could be used to install different
> scripts under the
> same name on different platforms (for example, a Mac OS
> X-specific script on
> Mac OS X, and a Tkinter script on Windows and other Unix systems).

It would seem more general to specify the full target name:

scripts=[
   Script('bin/dostuff.py', platforms="windows"),
   Script('bin/dostuff.py', target="bin/dostuff", platforms="posix"),

This doesn't handle a "default" platform though (ie, what would OSX do given
the above?)  Maybe we need "exclude_platforms" and "include_platforms"?

   Script('bin/dostuff.py',
          include_platforms="windows"),
   Script('bin/dostuff.py',
          target="bin/dostuff",
          exclude_platforms="windows"),

It is a real shame that setup.py has no foolproof access to the options
(such as the target platform) - then we could punt the problem right back
into setup.py - have it provide a different script list, possibly with
explicit target names, depending on the platform.

I'm wondering how close we are getting to YAGNI though.

> I've not determined what just the right interface would be
> between Script and
> the build_scripts and install_scripts commands; still
> thinking about that.

I'm still confused by build_scripts and install_scripts in general, and
still trying to understand a number of things I can't explain.  But I'm
getting there :)

Mark




More information about the Distutils-SIG mailing list