How to Convert a makefile to Python Script

Nick Vargish nav+posts at bandersnatch.org
Wed Apr 20 11:57:44 EDT 2005


rkoida at yahoo.com writes:

>    I am working on a Problem to convert makefile in to a python script.
> Are there any Modules? Please try to comment.

How about this (untested):

-------- cut here --------
import subprocess

print ("import os")
make = subprocess.Popen(["make", "-n"],stdout=subprocess.PIPE)
makeout = make.communicate()[0]
for l in makeout.split('\n'):
    print 'os.system("%s")' % l.replace('"', '\"')
-------- cut here --------

The quote escaping replace() might not be quite right, but you get
what I'm suggesting, right? To mangle a lwall quote, "The only
substitute for make is make."

Nick

-- 
# sigmask  (lambda deprecation version) 20041028 || feed this to a python
print ''.join([chr(ord(x)-1) for x in 'Ojdl!Wbshjti!=ojdlAwbshjti/psh?'])



More information about the Python-list mailing list