summaryrefslogtreecommitdiffstats
path: root/pygobject_postinstall.py
blob: b6e9d7abf8e9ebf294bc20362e1ddc4e17cdc595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

"""pygtk is now installed on your machine.



Local configuration files were successfully updated."""

import os, re, sys

prefix_pattern=re.compile("^prefix=.*")
exec_pattern=re.compile("^exec\s.*")

def replace_prefix(s):
    if prefix_pattern.match(s):
        s='prefix='+sys.prefix.replace("\\","\\\\")+'\n'
    if exec_pattern.match(s):
        s=('exec '+sys.prefix+'\\python.exe '+
           '$codegendir/codegen.py \"$@\"\n').replace("\\","\\\\")
    return s


if len(sys.argv) == 2 and sys.argv[1] == "-install":

    filenames=['lib/pkgconfig/pygtk-2.0.pc','bin/pygtk-codegen-2.0']
    for filename in filenames: 
        pkgconfig_file = os.path.normpath(
            os.path.join(sys.prefix,filename))

        lines=open(pkgconfig_file).readlines()
        open(pkgconfig_file, 'w').writelines(map(replace_prefix,lines))

    print __doc__