views:

406

answers:

2

Hi,

Please prompt me how to pass a user-defined parameter both from the command line and setup.cfg configuration file to distutils' setup.py script. I want to write a setup.py script, which accepts my package specific parameters. For example:

python setup.py install -foo myfoo

Thank you,
Mher

+2  A: 

You can't really pass custom parameters to the script. However the following things are possible and could solve your problem:

  • optional features can be enabled using --with-featurename, standard features can be disabled using --without-featurename. [AFAIR this requires setuptools]
  • you can use environment variables, these however require to be set on windows whereas prefixing them works on linux/ OS X (FOO=bar python setup.py).
  • you can extend distutils with your own cmd_classes which can implement new features. They are also chainable, so you can use that to change variables in your script. (python setup.py foo install) will execute the foo command before it executes install.

Hope that helps somehow. Generally speaking I would suggest providing a bit more information what exactly your extra parameter should do, maybe there is a better solution available.

Armin Ronacher
A: 

Hope that helps somehow.

Thank you for your answer!

Generally speaking I would suggest providing a bit more information what exactly your extra parameter should do, maybe there is a better solution available.

For successful installation of my package a user should provide the home directory of another program and several temporary directories.