Python in Makefile Question

Dan Bishop danb_83 at yahoo.com
Fri Feb 11 05:44:51 EST 2005


Efrat Regev wrote:
> Hello,
>
>     I'd like to ask a question concerning a python script in a
makefile.
> Suppose I have a C++ project (sorry for raising this in a Python
newsgroup),
> with some makefile for it. Before compiling the code, I'd like to
check that
> there are no C++ convention violations (e.g., identifiers beginning
with an
> underscore). So my makefile looks something like this:
>
> target: ...
>     verify.py
>     $(CC) ...
>
> verify.py is a python script that checks for convention violations,
i.e.,
> its first line is
>
> #! /usr/bin/env python
>
> I can't figure out the following:
> 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?

raise SystemExit(1)

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

Use command-line arguments.  The Python equivalent of "argv" is
"sys.argv".




More information about the Python-list mailing list