[pygtk] Setup.py cosmetic tidy



commit cd96aceda6f54dbceb7b64d6365fc1848eee52d1
Author: John Stowers <john stowers gmail com>
Date:   Thu Apr 15 13:40:26 2010 +1200

    Setup.py cosmetic tidy
    
         * Remove local doc install, point to website instead
         * link to versioned docs

 pygtk_postinstall.py |   68 +++++++++++++++++--------------------------------
 setup.py             |   15 ++---------
 2 files changed, 27 insertions(+), 56 deletions(-)
---
diff --git a/pygtk_postinstall.py b/pygtk_postinstall.py
index f33cc24..9caaa21 100644
--- a/pygtk_postinstall.py
+++ b/pygtk_postinstall.py
@@ -8,13 +8,14 @@ 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')
+pkgconfig_file = os.path.normpath(
+    os.path.join(sys.prefix,
+                 'lib/pkgconfig/pygtk-2.0.pc'))
 
 prefix_pattern=re.compile("^prefix=.*")
 exec_pattern=re.compile("^exec\s.*")
 codegendir_pattern=re.compile("^codegendir=.*")
+version_pattern=re.compile("Version: ([0-9]+\.[0-9]+\.[0-9]+)")
 
 def replace_prefix(s):
     if prefix_pattern.match(s):
@@ -28,29 +29,15 @@ def replace_prefix(s):
            '/gtk-2.0/codegen' + '\n')
     return s
 
-def copy_pygobject_css():
-    # Copy style.css from pygobject docs to pygtk docs
+def get_doc_url(pkgconfig_file, base_url):
     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
+        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)
@@ -61,21 +48,22 @@ 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/pygtk";)
     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)
+    create_shortcut(doc_url,'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)
+    create_shortcut("http://www.pygtk.org";,'PyGTK Homepage',homepage_link)
 
 def remove_shortcuts():
     pygtk_shortcuts = os.path.join(
@@ -90,19 +78,11 @@ def remove_shortcuts():
 
 if len(sys.argv) == 2:
     if sys.argv[1] == "-install":
-        filenames=['lib/pkgconfig/pygtk-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))
-        copy_pygobject_css()
-        html_fixxref()
+        # 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":
-        # remove_shortcuts()
-        os.remove(os.path.normpath(
-            os.path.join(sys.prefix,HTML_DIR,'style.css')))
+        remove_shortcuts()
diff --git a/setup.py b/setup.py
index 339d7c9..737c422 100755
--- a/setup.py
+++ b/setup.py
@@ -2,13 +2,7 @@
 #
 # setup.py - distutils configuration for pygtk
 #
-"""Python Bindings for the GTK Widget Set.
-
-PyGTK is a set of bindings for the GTK widget set. It provides an object
-oriented interface that is slightly higher level than the C one. It
-automatically does all the type casting and reference counting that you
-would have to do normally with the C API. You can find out more on the
-official homepage, http://www.daa.com.au/~james/pygtk/""";
+"""Python Bindings for the GTK Widget Set."""
 
 from distutils.command.build import build
 from distutils.core import setup
@@ -68,10 +62,6 @@ if sys.platform == 'win32':
 else:
     raise SystemExit("Error: distutils build only supported on windows")
 
-DEFS_DIR    = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs')
-INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX)
-HTML_DIR = os.path.join('share', 'gtk-doc', 'html', 'pygtk')
-
 if sys.version_info[:3] < MIN_PYTHON_VERSION:
     raise SystemExit("Python %s or higher is required, %s found" % (
         ".".join(map(str,MIN_PYTHON_VERSION)),
@@ -80,6 +70,8 @@ if sys.version_info[:3] < MIN_PYTHON_VERSION:
 if not have_pkgconfig():
     raise SystemExit("Error, could not find pkg-config")
 
+DEFS_DIR    = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs')
+INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX)
 PYGOBJECT_DEFSDIR = getoutput('pkg-config --variable=defsdir pygobject-2.0')
 
 class PyGtkInstallLib(InstallLib):
@@ -262,7 +254,6 @@ if gtk.can_build():
     data_files.append((DEFS_DIR, gtk_types_defs))
     data_files.append((DEFS_DIR, ('gtk/gdk-base-types.defs',
                                   'gtk/gtk-extrafuncs.defs')))
-    data_files.append((HTML_DIR, glob.glob('docs/html/*.html')))
     py_modules += ['gtk.compat', 'gtk.deprecation', 'gtk.keysyms',
                    'gtk._lazyutils']
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]