summaryrefslogtreecommitdiff
path: root/pygobject_postinstall.py
diff options
context:
space:
mode:
authorGraydon, Tracy <tracy.graydon@intel.com>2012-11-30 12:11:38 -0800
committerGraydon, Tracy <tracy.graydon@intel.com>2012-11-30 12:11:38 -0800
commit1a48cb6e7504163228442a2894af21af66e93eb2 (patch)
tree8d117e9778e44c485d187679bf5250c52e02975d /pygobject_postinstall.py
parente319390cebb45884f62ca3c2b22984d8ed82b941 (diff)
downloadpygobject2-1a48cb6e7504163228442a2894af21af66e93eb2.tar.gz
pygobject2-1a48cb6e7504163228442a2894af21af66e93eb2.tar.bz2
pygobject2-1a48cb6e7504163228442a2894af21af66e93eb2.zip
Update to 2.28 for TINF-96
Diffstat (limited to 'pygobject_postinstall.py')
-rw-r--r--pygobject_postinstall.py71
1 files changed, 4 insertions, 67 deletions
diff --git a/pygobject_postinstall.py b/pygobject_postinstall.py
index 487828e..bd546bf 100644
--- a/pygobject_postinstall.py
+++ b/pygobject_postinstall.py
@@ -1,72 +1,9 @@
+# -*- coding: utf-8 -*-
-"""pygobject is now installed on your machine.
-Local configuration files were successfully updated."""
+import sys
-import os, re, sys
-
-pkgconfig_file = os.path.normpath(
- os.path.join(sys.prefix,
- 'lib/pkgconfig/pygobject-2.0.pc'))
-
-prefix_pattern=re.compile("^prefix=.*")
-version_pattern=re.compile("Version: ([0-9]+\.[0-9]+\.[0-9]+)")
-
-def replace_prefix(s):
- if prefix_pattern.match(s):
- s='prefix='+sys.prefix.replace("\\","/")+'\n'
- s=s.replace("@DATADIR@",
- os.path.join(sys.prefix,'share').replace("\\","/"))
-
- return s
-
-def get_doc_url(pkgconfig_file, base_url):
- try:
- f = open(pkgconfig_file).read()
- ver = version_pattern.search(f).groups()[0]
- majv,minv,micv = ver.split('.')
- doc_url = "%s/%s.%s/" % (base_url,majv,minv)
- except:
- doc_url = base_url + "/stable/"
- return doc_url
-
-# TODO : Check that shortcuts are created system-wide when the user
-# has admin rights (hint: see pywin32 postinstall)
-def create_shortcuts():
- progs_folder= get_special_folder_path("CSIDL_COMMON_PROGRAMS")
- site_packages_dir = os.path.join(sys.prefix , 'lib','site-packages')
-
- pygtk_shortcuts = os.path.join(progs_folder, 'PyGTK')
- if not os.path.isdir(pygtk_shortcuts):
- os.mkdir(pygtk_shortcuts)
-
- # link to specific documentation version by parsing the
- # pkgconfig file
- doc_url = get_doc_url(pkgconfig_file,
- "http://library.gnome.org/devel/pygobject")
- pygobject_doc_link=os.path.join(pygtk_shortcuts,
- 'PyGObject Documentation.lnk')
- if os.path.isfile(pygobject_doc_link):
- os.remove(pygobject_doc_link)
- create_shortcut(doc_url,'PyGObject Documentation',pygobject_doc_link)
-
-def remove_shortcuts():
- pygtk_shortcuts = os.path.join(
- get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'PyGTK')
- os.remove(os.path.join(pygtk_shortcuts,'PyGObject Documentation.lnk'))
- try:
- os.rmdir(pygtk_shortcuts)
- except OSError, e:
- # Directory is not empty, so leave it like that !
- pass
if len(sys.argv) == 2:
- if sys.argv[1] == "-install":
- # fixup the pkgconfig file
- lines=open(pkgconfig_file).readlines()
- open(pkgconfig_file, 'w').writelines(map(replace_prefix,lines))
- # TODO: Add an installer option for shortcut creation
- create_shortcuts()
- print __doc__
- elif sys.argv[1] == "-remove":
- remove_shortcuts()
+ if sys.argv[1] == '-install':
+ print ('pygobject is now installed on your machine.\n')