how to add command line flags to distutils setup script?

S

skip

Suppose I have a setup.py script which imports distutils.core.setup. Is
there some way to, for example, add a command line flag to the build command
so that I can run it like

python setup.py build --frob=True

? I see that the setup function takes an options parameter but the
distutils.core.setup doc says little other than that it is a string and
"default options for the setup script". There is also a script_args
parameter, but the docs are similarly mum about what exactly it's used for.
A posting by Greg Ward announcing it in Aug 2000 says script_args is a sub
for sys.argv[1:].

Pointers to other documentation or tutorials on the topic cheerfully
appreciated.

Thanks,
 
M

Martin v. Löwis

Suppose I have a setup.py script which imports distutils.core.setup. Is
there some way to, for example, add a command line flag to the build command
so that I can run it like

python setup.py build --frob=True

?

You should inherit from the build command, extend the user_options
attribute, and pass the new class as "build" class into the commands
dictionary of setup. You might need to extend initialize_options and
finalize_options as well.

Regards,
Martin
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top