diff options
author | Cedric Gustin <cedric.gustin@gmail.com> | 2006-09-21 07:16:38 +0000 |
---|---|---|
committer | Cedric Gustin <gustin@src.gnome.org> | 2006-09-21 07:16:38 +0000 |
commit | 39d90f0e695591deea2fc834afd5e0edae5cd229 (patch) | |
tree | b7d82ce0c91acc600e74a150650741281bff71ce | |
parent | 098622712405942798a7241f5016ab73fea2529b (diff) | |
download | pygtk-39d90f0e695591deea2fc834afd5e0edae5cd229.tar.gz |
Adapt the codegendir variable to the user platform. Copy style.css from
2006-09-21 Cedric Gustin <cedric.gustin@gmail.com>
* pygtk_postinstall.py: Adapt the codegendir variable to the user
platform. Copy style.css from pygobject docs to pygtk docs. Run
fixxref on installed html files. Add functions to install
shortcuts in the Start menu to the reference manual (currently
disabled: see bug #353849).
* setup.py: Changed the way the VERSION macro is defined on
win32. Added 2.10 defs files for gdk and gtk when GTK+ 2.10 is
detected. Added gtk.keysyms, gtk._lazyutils, dsextras_gen and
codegen to the list of installed packages. Also install the html
reference documentation and run fixxref on the html files.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | pygtk_postinstall.py | 138 | ||||
-rwxr-xr-x | setup.py | 64 |
3 files changed, 170 insertions, 45 deletions
@@ -1,3 +1,16 @@ +2006-09-21 Cedric Gustin <cedric.gustin@gmail.com> + + * pygtk_postinstall.py: Adapt the codegendir variable to the user + platform. Copy style.css from pygobject docs to pygtk docs. Run + fixxref on installed html files. Add functions to install + shortcuts in the Start menu to the reference manual (currently + disabled: see bug #353849). + * setup.py: Changed the way the VERSION macro is defined on + win32. Added 2.10 defs files for gdk and gtk when GTK+ 2.10 is + detected. Added gtk.keysyms, gtk._lazyutils, dsextras_gen and + codegen to the list of installed packages. Also install the html + reference documentation and run fixxref on the html files. + 2006-09-16 Gustavo J. A. M. Carneiro <gjc@gnome.org> * gtk/pygtkcellrenderer.c (pygtk_generic_cell_renderer_activate): diff --git a/pygtk_postinstall.py b/pygtk_postinstall.py index b6e9d7ab..627bc12b 100644 --- a/pygtk_postinstall.py +++ b/pygtk_postinstall.py @@ -1,30 +1,108 @@ -
-"""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__
+ +"""pygtk is now installed on your machine. + +Local configuration files were successfully updated.""" + +import os, os.path, re, sys +import distutils.sysconfig +import distutils.file_util +import distutils.errors + +PYGOBJECT_XSL_DIR = os.path.join('share', 'pygobject','xsl') +PYGOBJECT_HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygobject') +HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygtk') + +prefix_pattern=re.compile("^prefix=.*") +exec_pattern=re.compile("^exec\s.*") +codegendir_pattern=re.compile("^codegendir=.*") + +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("\\","/") + if codegendir_pattern.match(s): + s=('codegendir=' + +distutils.sysconfig.get_python_lib().replace("\\","/")+ + '/gtk-2.0/codegen' + '\n') + return s + +def copy_pygobject_css(): + # Copy style.css from pygobject docs to pygtk docs + try: + distutils.file_util.copy_file( + os.path.normpath(os.path.join(sys.prefix, PYGOBJECT_HTML_DIR, + 'style.css')), + os.path.normpath(os.path.join(sys.prefix,HTML_DIR))) + except distutils.errors.DistutilsFileError: + # probably pygobject has not been installed yet + pass + + + +def html_fixxref(): + sys.path.insert(0, os.path.normpath(os.path.join(sys.prefix, + PYGOBJECT_XSL_DIR))) + try: + import fixxref + fixxref.scan_index_dir(fixxref.DOCDIR) + fixxref.fix_xrefs(os.path.normpath(os.path.join(sys.prefix, + HTML_DIR))) + except ImportError, e: + pass + +# 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) + + pygtk_doc_link=os.path.join(pygtk_shortcuts, + 'PyGTK Documentation.lnk') + if os.path.isfile(pygtk_doc_link): + os.remove(pygtk_doc_link) + + create_shortcut(os.path.join(sys.prefix,'share','gtk-doc','html', + 'pygtk','index.html'), + 'PyGTK Documentation', pygtk_doc_link) + + homepage_link = os.path.join(pygtk_shortcuts, + "PyGTK Home.lnk") + if os.path.isfile(homepage_link): + os.remove(homepage_link) + create_shortcut("http://www.pygtk.org",'PyGTK Homepage', homepage_link) + +def remove_shortcuts(): + pygtk_shortcuts = os.path.join( + get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'PyGTK') + os.remove(os.path.join(pygtk_shortcuts,'PyGTK Documentation.lnk')) + os.remove(os.path.join(pygtk_shortcuts,'PyGTK Home.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/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)) + copy_pygobject_css() + html_fixxref() + # TODO: Add an installer option for shortcut creation + # create_shortcuts() + print __doc__ + elif sys.argv[1] == "-remove": + # remove_shortcuts() + os.remove(os.path.normpath( + os.path.join(sys.prefix,HTML_DIR,'style.css'))) @@ -16,13 +16,16 @@ official homepage, http://www.daa.com.au/~james/pygtk/""" from distutils.command.build import build from distutils.core import setup +import glob import os import sys -from dsextras import get_m4_define, getoutput, have_pkgconfig, list_files, \ +from dsextras import get_m4_define, getoutput, have_pkgconfig, \ + pkgc_version_check, \ GLOBAL_INC, GLOBAL_MACROS, InstallLib, InstallData, BuildExt, \ PkgConfigExtension, Template, TemplateExtension + if '--yes-i-know-its-not-supported' in sys.argv: sys.argv.remove('--yes-i-know-its-not-supported') else: @@ -38,10 +41,10 @@ else: if not input.startswith('y'): raise SystemExit -if sys.version_info[:3] < (2, 3, 5): - raise SystemExit, \ - "Python 2.3.5 or higher is required, %d.%d.%d found" % sys.version_info[:3] - + if sys.version_info[:3] < (2, 3, 5): + raise SystemExit, \ + "Python 2.3.5 or higher is required, %d.%d.%d found" % sys.version_info[:3] + MAJOR_VERSION = int(get_m4_define('pygtk_major_version')) MINOR_VERSION = int(get_m4_define('pygtk_minor_version')) MICRO_VERSION = int(get_m4_define('pygtk_micro_version')) @@ -64,7 +67,7 @@ GLOBAL_MACROS += [('PYGTK_MAJOR_VERSION', MAJOR_VERSION), ('PYGTK_MICRO_VERSION', MICRO_VERSION)] if sys.platform == 'win32': - GLOBAL_MACROS.append(('VERSION', '\\\"%s\\\"' % VERSION)) + GLOBAL_MACROS.append(('VERSION', '"""%s"""' % VERSION)) GLOBAL_MACROS.append(('PLATFORM_WIN32',1)) GLOBAL_MACROS.append(('HAVE_BIND_TEXTDOMAIN_CODESET',1)) else: @@ -73,6 +76,7 @@ else: DEFS_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs') CODEGEN_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'codegen') INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX) +HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygtk') class PyGtkInstallLib(InstallLib): def run(self): @@ -143,10 +147,14 @@ pangocairo = TemplateExtension(name='pangocairo', # Gdk (template only) gdk_template = Template('gtk/gdk.override', 'gtk/gdk.c', - defs='gtk/gdk.defs', prefix='pygdk', + defs=('gtk/gdk.defs', + ['gtk/gdk-2.10.defs','gtk/gdk-base.defs']), + prefix='pygdk', register=['atk-types.defs', 'pango-types.defs', - 'gtk/gdk-types.defs']) + ('gtk/gdk-types.defs', + ['gtk/gdk-base-types.defs'])] + ) # Gtk+ if pangocairo.can_build(): gtk_pkc_name=('gtk+-2.0','pycairo') @@ -155,6 +163,24 @@ else: gtk_pkc_name='gtk+-2.0' gtk_pkc_version=GTK_REQUIRED +if pkgc_version_check('gtk+-2.0', '2.10.0'): + gtk_pkc_defs=('gtk/gtk.defs',['gtk/gtk-2.10.defs','gtk/gtk-base.defs']) + gtk_pkc_register=['pango-types.defs', + ('gtk/gdk-types.defs',['gtk/gdk-base-types.defs']), + ('gtk/gtk-types.defs',['gtk/gtk-base-types.defs', + 'gtk/gtk-2.10-types.defs'])] + libglade_pkc_register=[('gtk/gtk-types.defs', + ['gtk/gtk-base-types.defs', + 'gtk/gtk-2.10-types.defs']), + 'gtk/libglade.defs'] +else: + gtk_pkc_defs=('gtk/gtk.defs',['gtk/gtk-base.defs']) + gtk_pkc_register=['pango-types.defs', + ('gtk/gdk-types.defs',['gtk/gdk-base-types.defs']), + ('gtk/gtk-types.defs',['gtk/gtk-base-types.defs'])] + libglade_pkc_register=[('gtk/gtk-types.defs',['gtk/gtk-base-types.defs']), + 'gtk/libglade.defs'] + gtk = TemplateExtension(name='gtk', pkc_name=gtk_pkc_name, pkc_version=gtk_pkc_version, output='gtk._gtk', @@ -165,11 +191,10 @@ gtk = TemplateExtension(name='gtk', pkc_name=gtk_pkc_name, 'gtk/pygtkcellrenderer.c', 'gtk/gdk.c', 'gtk/gtk.c'], - register=['pango-types.defs', - 'gtk/gdk-types.defs', - 'gtk/gtk-types.defs'], + register=gtk_pkc_register, override='gtk/gtk.override', - defs='gtk/gtk.defs') + defs=gtk_pkc_defs + ) gtk.templates.append(gdk_template) # Libglade @@ -179,13 +204,13 @@ libglade = TemplateExtension(name='libglade', pkc_name='libglade-2.0', defs='gtk/libglade.defs', sources=['gtk/libglademodule.c', 'gtk/libglade.c'], - register=['gtk/gtk-types.defs', - 'gtk/libglade.defs'], + register=libglade_pkc_register, override='gtk/libglade.override') data_files = [] ext_modules = [] py_modules = [] +packages = ['codegen'] if not have_pkgconfig(): print "Error, could not find pkg-config" @@ -215,9 +240,17 @@ if gtk.can_build(): ext_modules.append(gtk) data_files.append((os.path.join(INCLUDE_DIR, 'pygtk'), ('gtk/pygtk.h',))) data_files.append((DEFS_DIR, ('gtk/gdk.defs', 'gtk/gdk-types.defs', + 'gtk/gdk-base.defs', + 'gtk/gdk-base-types.defs', 'gtk/gtk.defs', 'gtk/gtk-types.defs', + 'gtk/gtk-2.10.defs', + 'gtk/gtk-2.10-types.defs', + 'gtk/gtk-base.defs', + 'gtk/gtk-base-types.defs', 'gtk/gtk-extrafuncs.defs'))) - py_modules += ['gtk.compat', 'gtk.keysyms'] + data_files.append((HTML_DIR, glob.glob('docs/html/*.html'))) + py_modules += ['gtk.compat', 'gtk.deprecation', 'gtk.keysyms', + 'gtk._lazyutils'] if libglade.can_build(): ext_modules.append(libglade) @@ -272,6 +305,7 @@ setup(name="pygtk", description = doclines[0], long_description = "\n".join(doclines[2:]), py_modules=py_modules, + packages=packages, ext_modules=ext_modules, data_files=data_files, scripts = ["pygtk_postinstall.py"], |