diff options
author | John Stowers <john.stowers@gmail.com> | 2010-04-15 13:40:39 +1200 |
---|---|---|
committer | John Stowers <john.stowers@gmail.com> | 2010-04-16 22:29:04 +1200 |
commit | e580da87f0b2fd36cb5d8008fb2fb0c3b01f456a (patch) | |
tree | 3ceadc0f7559aa05edacc883d1abc9ef486dcf66 /pygobject_postinstall.py | |
parent | 69ecd506c83ddf180c6cc9a2a8dc753a02543959 (diff) | |
download | pygobject-e580da87f0b2fd36cb5d8008fb2fb0c3b01f456a.tar.gz |
Setup.py cosmetic tidy
* Remove local doc install, point to website instead
* link to versioned docs
Diffstat (limited to 'pygobject_postinstall.py')
-rw-r--r-- | pygobject_postinstall.py | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/pygobject_postinstall.py b/pygobject_postinstall.py index 8ddaa604..487828e4 100644 --- a/pygobject_postinstall.py +++ b/pygobject_postinstall.py @@ -5,8 +5,12 @@ Local configuration files were successfully updated.""" import os, re, sys -prefix_pattern=re.compile("^prefix=.*") +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): @@ -16,6 +20,16 @@ def replace_prefix(s): 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(): @@ -25,15 +39,16 @@ def create_shortcuts(): 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(os.path.join(sys.prefix,'share','gtk-doc','html', - 'pygobject','index.html'), - 'PyGObject Documentation', pygobject_doc_link) + create_shortcut(doc_url,'PyGObject Documentation',pygobject_doc_link) def remove_shortcuts(): pygtk_shortcuts = os.path.join( @@ -47,17 +62,11 @@ def remove_shortcuts(): if len(sys.argv) == 2: if sys.argv[1] == "-install": - filenames=['lib/pkgconfig/pygobject-2.0.pc', - 'share/pygobject/xsl/fixxref.py'] - 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)) + # 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() + create_shortcuts() print __doc__ elif sys.argv[1] == "-remove": - pass - # remove_shortcuts() + remove_shortcuts() |