distutils question

Martin von Loewis loewis at informatik.hu-berlin.de
Thu May 24 10:59:11 EDT 2001

Toby J Sargeant <tjs at mail.csse.monash.edu.au> writes:

> Is there any way to add to the command line arguments that a distutils
> aware package understands? i went down this route:
> class my_build(build):
>    user_options=build.user_options+[
>       ('freetype-dir=',None,"root directory of freetype install")
>       ]
> and failed dismally -- the new argument shows up in the --help list, but
> doesn't seem to be included in the information passed to getopt.

This is a good starting point, but you'll also have to provide logic
to access the settings. First, you need to extend .initialize_options()
for the case that no freetype-dir is specified:

     def initialize_options(self):
       self.freetype_dir = None

Then, you may want to extend finalize_options to come up with a value
in case you need some logic there, see distutils.cmd.Command.__doc__
for details.

Finally, you probably want to override .run() to access freetype_dir.
If you follow this route, it should work fine.

> more geenerally, what's the preferred way of adding user specified paths
> for includes and libraries?

The preferred way, of course, is that setup.py automatically guess the
right paths. If that fails, using command line options is fine, as is
using environment variables (atleast on Unix).

For command line options, you need to decide whether they apply only
to a single command or subcommand, or to the entire distribution.


More information about the Python-list mailing list