Python in Makefile Question

Daniel Dittmar daniel.dittmar at sap.corp
Fri Feb 11 05:47:46 EST 2005


Efrat Regev wrote:
> 1. How can I get the python script to return a value to make, so that if it
> decides that there are convention violations make will fail?

You can set the return code of your Python script through sys.exit (3)

> 2. How can I pass information from the makefile to the python script, e.g.,
> the base directory to check?

Python side:
Commandline arguments can be read through the list sys.argv. Parsing of 
commandline options can be done with the module optparse.

Makefile side:
I don't know if there is a special variable in GNU make for the 
directory of the current target. Why don't you set the default for the 
directory option to the current directory? Most Makefiles won't work 
anyway if they are called from a different directory.

Daniel



More information about the Python-list mailing list