/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/version.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/version.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 922 by frank, Mon May 19 09:12:07 2003 UTC revision 2682 by dpinte, Mon May 15 20:11:15 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  # Copyright (C) 2002, 2003, 2004 by Intevation GmbH
 #  
 # Copyright (C) 2002, 2003 by Intevation GmbH  
2  # Authors:  # Authors:
3  # Thomas Koester <[email protected]>  # Thomas Koester <[email protected]>
4  # Frank Koormann <[email protected]>  # Frank Koormann <[email protected]>
# Line 17  __version__ = "$Revision$" Line 15  __version__ = "$Revision$"
15  # $Id$  # $Id$
16    
17    
18  version = 'cvs'  # Note that this file defines the version number of Thuban for the about
19  append_date = 1  # dialog.
20    
21    # The thuban version string is build from two values, thuban_branch and
22    # thuban_release.  If release is "cvs" the code is from a non-released
23    # cvs version and the version string is built from the branch, the
24    # release and an approximation of the date (e.g. the most recent date of
25    # the ChangeLog file or the most recent modification time of a source
26    # file).  Otherwise the string is build from the branch and the release.
27    # E.g. given
28    #
29    #  thuban_branch = "1.1"
30    #  thuban_release = "svn"
31    #
32    # the version string will be "Thuban 1.1 svn-20040224" (obviously the
33    # actual date might differ :) ).  OTOH, given
34    #
35    #  thuban_branch = "1.0"
36    #  thuban_release = "1"
37    #
38    # the version string will be "Thuban 1.0.1"
39    #
40    
41    thuban_branch = "1.1"
42    thuban_release = "svn"
43    
44    
45    
46  import os, os.path  import sys, os, os.path
47  import time  import time
48    from string import split
49    
50    from Thuban import  _
51    from Thuban.Lib.version import make_tuple
52    
53  if __name__ == "__main__":  if __name__ == "__main__":
54      import sys      import sys
# Line 48  def get_date(format): Line 74  def get_date(format):
74    
75  def get_changelog_date():  def get_changelog_date():
76      changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")      changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")
77      file = open(changelog, "r")      try:
78      line = file.readline()          file = open(changelog, "r")
79      file.close()          line = file.readline()
80      return line.split(" ")[0]          file.close()
81        except:
82  if append_date:          return ""
83      version = '%s-%s' % (version, get_date('%Y%m%d'))      return 'ChangeLog %s' % line.split(" ")[0]
84  longversion = '%s\n  ChangeLog %s' % (version, get_changelog_date())  
85  #longversion = 'Thuban Release Version 0.2'  
86    #
87    # Fill in versions with the different versions of the libraries
88    # that Thuban is using or requires (only if those libraries are
89    # available.
90    #
91    
92    versions = {}
93    
94    if thuban_release == "svn":
95        version = '%s %s-%s' % (thuban_branch, thuban_release, get_date('%Y%m%d'))
96        longversion = '%s\n%s' % (version, get_changelog_date())
97    else:
98        version = thuban_branch + "." + thuban_release
99        longversion = 'Release Version ' + version
100    
101    versions['thuban'] = version
102    versions['thuban-long'] = longversion
103    
104    # wxPython
105    from wxPython.wx import __version__ as wxPython_version
106    versions['wxPython'] = wxPython_version
107    versions['wxPython-tuple'] = make_tuple(wxPython_version)
108    
109    # Python
110    versions['python'] = "%d.%d.%d" % sys.version_info[:3]
111    versions['python-tuple'] = sys.version_info[:3]
112    
113    # PySQLite
114    try:
115        from pysqlite2 import dbapi2 as sqlite
116    except ImportError:
117        import sqlite
118    versions['pysqlite'] = sqlite.version
119    versions['pysqlite-tuple'] = make_tuple(sqlite.version)
120    
121    # SQLite
122    try:
123        from pysqlite2._sqlite import sqlite_version
124    except ImportError:
125        from _sqlite import sqlite_version
126    versions['sqlite'] = sqlite_version
127    versions['sqlite-tuple'] = make_tuple(sqlite_version)
128    
129    # GDAL
130    from  Thuban.Model.resource import has_gdal_support
131    if has_gdal_support():
132        from gdalwarp import get_gdal_version
133        versions['gdal'] = get_gdal_version()
134        versions['gdal-tuple'] = make_tuple(get_gdal_version())
135    
136    from wxproj import get_proj_version, get_gtk_version, get_wx_version
137    
138    # GTK
139    gtk_ver = get_gtk_version()
140    if gtk_ver:
141        versions['gtk'] = ".".join(map(str, gtk_ver))
142        versions['gtk-tuple'] = gtk_ver
143    
144    # PROJ
145    proj_ver = get_proj_version()
146    if proj_ver:
147        versions['proj'] = ".".join(map(str, proj_ver))
148        versions['proj-tuple'] = proj_ver
149    
150    wxproj_wx_version = get_wx_version()
151    versions['wxproj-wx'] = ".".join(map(str, wxproj_wx_version))
152    versions['wxproj-wx-tuple'] = wxproj_wx_version
153    
154    
155    # psycopg/postgis
156    import Thuban.Model.postgisdb
157    if Thuban.Model.postgisdb.has_postgis_support():
158        v = Thuban.Model.postgisdb.psycopg_version()
159        versions['psycopg'] = v
160        versions['psycopg-tuple'] = make_tuple(v)
161    
162    def verify_versions():
163        """Verify that Thuban is using the correct versions of libraries.
164    
165        Returns a non-empty list of strings indicating which libraries
166        are wrong, or the empty list if everthing is ok.
167        """
168    
169        #
170        # The 'name' below must correspong to an mapping in 'versions'.
171        # There must also exist a 'name'-tuple mapping.
172        #
173        #         title           name       version
174        list = [["Python",      "python",   (2, 2, 1)],
175                ["wxPython",    "wxPython", (2, 4, 0)],
176                ["SQLite",      "sqlite",   (2, 8, 0)],
177                ["PySQLite",    "pysqlite", (0, 4, 1)],
178                ["PROJ",        "proj",     (4, 4, 5)],
179                ["GTK",         "gtk",      (1, 2, 3)],
180                ["GDAL",        "gdal",     (1, 1, 8)]]
181    
182        errors = []
183        for title, name, version in list:
184            tup = versions.get("%s-tuple" % name, None)
185            if tup and tup < version:
186                errors.append(_("%s %s < %s") % \
187                              (title, versions[name], ".".join(map(str, version))))
188    
189        # Check whether the wxWindows version of wxPython and thuban's
190        # wxproj module match.  If they don't match, segfaults are likely.
191        if versions["wxproj-wx-tuple"] != versions["wxPython-tuple"][:3]:
192            errors.append(_("Thuban was compiled with wx %(wxproj-wx)s"
193                            " but wxPython is %(wxPython)s")
194                          % versions)
195    
196        return errors
197    
198  if __name__ == "__main__":  if __name__ == "__main__":
199      print longversion      print longversion
200    

Legend:
Removed from v.922  
changed lines
  Added in v.2682

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26