Update Enums and Flags with new API
[pygobject.git] / pygobject_postinstall.py
blob8ddaa604eeb0a83f7d3ec482a5ae7483ebb5b915
2 """pygobject is now installed on your machine.
4 Local configuration files were successfully updated."""
6 import os, re, sys
8 prefix_pattern=re.compile("^prefix=.*")
11 def replace_prefix(s):
12 if prefix_pattern.match(s):
13 s='prefix='+sys.prefix.replace("\\","/")+'\n'
14 s=s.replace("@DATADIR@",
15 os.path.join(sys.prefix,'share').replace("\\","/"))
17 return s
19 # TODO : Check that shortcuts are created system-wide when the user
20 # has admin rights (hint: see pywin32 postinstall)
21 def create_shortcuts():
22 progs_folder= get_special_folder_path("CSIDL_COMMON_PROGRAMS")
23 site_packages_dir = os.path.join(sys.prefix , 'lib','site-packages')
25 pygtk_shortcuts = os.path.join(progs_folder, 'PyGTK')
26 if not os.path.isdir(pygtk_shortcuts):
27 os.mkdir(pygtk_shortcuts)
29 pygobject_doc_link=os.path.join(pygtk_shortcuts,
30 'PyGObject Documentation.lnk')
31 if os.path.isfile(pygobject_doc_link):
32 os.remove(pygobject_doc_link)
34 create_shortcut(os.path.join(sys.prefix,'share','gtk-doc','html',
35 'pygobject','index.html'),
36 'PyGObject Documentation', pygobject_doc_link)
38 def remove_shortcuts():
39 pygtk_shortcuts = os.path.join(
40 get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'PyGTK')
41 os.remove(os.path.join(pygtk_shortcuts,'PyGObject Documentation.lnk'))
42 try:
43 os.rmdir(pygtk_shortcuts)
44 except OSError, e:
45 # Directory is not empty, so leave it like that !
46 pass
48 if len(sys.argv) == 2:
49 if sys.argv[1] == "-install":
50 filenames=['lib/pkgconfig/pygobject-2.0.pc',
51 'share/pygobject/xsl/fixxref.py']
52 for filename in filenames:
53 pkgconfig_file = os.path.normpath(
54 os.path.join(sys.prefix,filename))
56 lines=open(pkgconfig_file).readlines()
57 open(pkgconfig_file, 'w').writelines(map(replace_prefix,lines))
58 # TODO: Add an installer option for shortcut creation
59 # create_shortcuts()
60 print __doc__
61 elif sys.argv[1] == "-remove":
62 pass
63 # remove_shortcuts()