diff options
author | Cedric Gustin <cedric.gustin@gmail.com> | 2006-09-21 07:13:40 +0000 |
---|---|---|
committer | Cedric Gustin <gustin@src.gnome.org> | 2006-09-21 07:13:40 +0000 |
commit | 16d397d8f104b04c4de5f97957b5ae5cc6d27b74 (patch) | |
tree | 7c610c061e044ac80689d4d2bf3e4adad2640853 /pygobject_postinstall.py | |
parent | 7e823bfb034b82377d092e954d9f73c48af5795f (diff) | |
download | pygobject-16d397d8f104b04c4de5f97957b5ae5cc6d27b74.tar.gz pygobject-16d397d8f104b04c4de5f97957b5ae5cc6d27b74.tar.xz pygobject-16d397d8f104b04c4de5f97957b5ae5cc6d27b74.zip |
Catch ImportError exception when codegen is not available: disable
2006-09-21 Cedric Gustin <cedric.gustin@gmail.com>
* dsextras.py: Catch ImportError exception when codegen is not
available: disable Template and TemplateExtension, redirect the
user to the pygtk installer and raise a NameError
exception. check_date has also been rewritten and now uses
distutils.dep_util.newer_group(). defs files can also be built
using createdefs by passing tuples as keyword argument to Template
(see for example the gdk and gtk templates in setup.py).
* setup.py: Changed the way the VERSION macro is defined on win32.
Also install the html reference documentation, the xsl files and
fixxref.
* pygobject_postinstall.py: Set the value of DATADIR in
fixxref.py. Add functions to install shortcuts in the Start menu
to the reference manual (currently disabled: see bug #353849).
Diffstat (limited to 'pygobject_postinstall.py')
-rw-r--r-- | pygobject_postinstall.py | 89 |
1 files changed, 63 insertions, 26 deletions
diff --git a/pygobject_postinstall.py b/pygobject_postinstall.py index 0175d00..8ddaa60 100644 --- a/pygobject_postinstall.py +++ b/pygobject_postinstall.py @@ -1,26 +1,63 @@ -
-"""pygtk is now installed on your machine.
-
-Local configuration files were successfully updated."""
-
-import os, re, sys
-
-prefix_pattern=re.compile("^prefix=.*")
-
-def replace_prefix(s):
- if prefix_pattern.match(s):
- s='prefix='+sys.prefix.replace("\\","\\\\")+'\n'
- return s
-
-
-if len(sys.argv) == 2 and sys.argv[1] == "-install":
-
- filenames=['lib/pkgconfig/pygobject-2.0.pc']
- 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__
+ +"""pygobject is now installed on your machine. + +Local configuration files were successfully updated.""" + +import os, re, sys + +prefix_pattern=re.compile("^prefix=.*") + + +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 + +# 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) + + 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) + +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": + 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)) + # TODO: Add an installer option for shortcut creation + # create_shortcuts() + print __doc__ + elif sys.argv[1] == "-remove": + pass + # remove_shortcuts() |