Calling GNU/make from a Python Script

sjdevnull at yahoo.com sjdevnull at yahoo.com
Mon Oct 30 13:27:46 EST 2006


skip at pobox.com wrote:
> Fredrik> build_dir = "path/to/makefile"
>
>     Fredrik> cwd = os.getcwd() # get current directory
>     Fredrik> try:
>     Fredrik>      os.chdir(build_dir)
>     Fredrik>      os.system("make")
>     Fredrik> finally:
>     Fredrik>      os.chdir(cwd)
>
> Or even:
>
>     os.system("make -C %s" % build_dir)

OP specified GNU make, so that works fine, but make sure you're not
going to need to use it with another make before settling on that
alternative.  Frederik's works with more versions of make.




More information about the Python-list mailing list