Calling GNU/make from a Python Script

Rob Williscroft rtw at freenet.co.uk
Mon Oct 30 09:16:42 EST 2006


Efrat Regev wrote in news:45462091 at news.bezeqint.net in comp.lang.python:

>    Hello,
> 
>    I need to call GNU/make from within a Python script. This raised some 
> problems:
> 1. The script is not in the directory of the makefile, and changing the 
> locations of either is not an option. Consequently, the makefile fails, 
> since it can't find the targets/dependencies.
> 2. After searching around, it seems that os.system(..) should be avoided 
>   if there's an alternative. Is there one in this case?
> 

USe the subprocess module, in particular see

Popen: http://docs.python.org/lib/node529.html

and call: http://docs.python.org/lib/node530.html

you will need to use the "cwd" argument.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list