Staging
v0.5.1
https://github.com/python/cpython
Revision 2032722e514a20b5f5321f07427dc2cea6e0d634 authored by Antoine Pitrou on 24 May 2009, 20:39:11 UTC, committed by Antoine Pitrou on 24 May 2009, 20:39:11 UTC
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72898 | antoine.pitrou | 2009-05-24 22:23:57 +0200 (dim., 24 mai 2009) | 6 lines

  Issue #3585: Add pkg-config support.

  It creates a python-2.7.pc file and a python.pc symlink in the
  $(LIBDIR)/pkgconfig directory. Patch by Clinton Roy.
........
1 parent 70ccd16
Raw File
Tip revision: 2032722e514a20b5f5321f07427dc2cea6e0d634 authored by Antoine Pitrou on 24 May 2009, 20:39:11 UTC
Merged revisions 72898 via svnmerge from
Tip revision: 2032722
fixps.py
#!/usr/bin/env python

# Fix Python script(s) to reference the interpreter via /usr/bin/env python.
# Warning: this overwrites the file without making a backup.

import sys
import re


def main():
    for filename in sys.argv[1:]:
        try:
            f = open(filename, 'r')
        except IOError as msg:
            print(filename, ': can\'t open :', msg)
            continue
        line = f.readline()
        if not re.match('^#! */usr/local/bin/python', line):
            print(filename, ': not a /usr/local/bin/python script')
            f.close()
            continue
        rest = f.read()
        f.close()
        line = re.sub('/usr/local/bin/python',
                      '/usr/bin/env python', line)
        print(filename, ':', repr(line))
        f = open(filename, "w")
        f.write(line)
        f.write(rest)
        f.close()

if __name__ == '__main__':
    main()
back to top