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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2088 - (hide annotations)
Wed Feb 25 10:33:24 2004 UTC (21 years ago) by bh
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 5939 byte(s)
* libraries/thuban/wxproj.cpp (get_wx_version): New.  Return the
version of wxWindows the module was compiled with so we can check
that against the wxPython version.

* Thuban/version.py (thuban_branch, thuban_release): New variables
controlling which and how Thuban versions are shown.  See the
comments for details.
(verify_versions): Also check that the wx version that wxproj is
compiled against matches that of the wxPython we use at runtime

1 bh 2088 # Copyright (C) 2002, 2003, 2004 by Intevation GmbH
2 frank 922 # Authors:
3     # Thomas Koester <[email protected]>
4     # Frank Koormann <[email protected]>
5     #
6     # This program is free software under the GPL (>=v2)
7     # Read the file COPYING coming with the software for details.
8    
9     """
10     Thuban version information
11     """
12    
13     __version__ = "$Revision$"
14     # $Source$
15     # $Id$
16    
17    
18 bh 2088 # Note that this file defines the version number of Thuban for the about
19     # dialog.
20 frank 922
21 bh 2088 # 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 = "cvs"
31     #
32     # the version string will be "Thuban 1.1 cvs 2004-02-24" (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 frank 922
41 bh 2088 thuban_branch = "1.1"
42     thuban_release = "cvs"
43    
44    
45    
46 jonathan 1306 import sys, os, os.path
47 frank 922 import time
48 jonathan 1306 from string import split
49 frank 922
50 jonathan 1306 from Thuban import _
51 bh 2011 from Thuban.Lib.version import make_tuple
52 jonathan 1306
53 frank 922 if __name__ == "__main__":
54     import sys
55     __file__ = sys.argv[0]
56    
57     def is_relevant_file(file):
58     """check if a file is relevant for determining the current version"""
59     extensions = ['.py', '.xpm', '.c', '.h']
60     return os.path.isfile(file) and os.path.splitext(file)[1] in extensions
61    
62     def visit(args, dirname, names):
63     """helper for os.path.walk; save mtime of newest file for this directory"""
64     files = filter(is_relevant_file,
65     [os.path.join(dirname, file) for file in names])
66     args['max'] = max([args['max']] + map(os.path.getmtime, files))
67    
68     def get_date(format):
69     """strftime formatted mtime of the newest relevant file"""
70     dir = os.path.dirname(os.path.abspath(__file__))
71     args = {'max': 0}
72     os.path.walk(dir, visit, args)
73     return time.strftime(format, time.localtime(args['max']))
74    
75     def get_changelog_date():
76     changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")
77 frank 925 try:
78     file = open(changelog, "r")
79     line = file.readline()
80     file.close()
81     except:
82     return ""
83 jonathan 1306 return 'ChangeLog %s' % line.split(" ")[0]
84 frank 922
85 jonathan 1306
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 bh 2088 if thuban_release == "cvs":
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 jonathan 1306 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 jonathan 1322 versions['wxPython-tuple'] = make_tuple(wxPython_version)
108 jonathan 1306
109     # Python
110     versions['python'] = "%d.%d.%d" % sys.version_info[:3]
111     versions['python-tuple'] = sys.version_info[:3]
112    
113     # PySQLite
114     from sqlite import version as pysqlite_version
115     versions['pysqlite'] = pysqlite_version
116 jonathan 1322 versions['pysqlite-tuple'] = make_tuple(pysqlite_version)
117 jonathan 1306
118     # SQLite
119     from _sqlite import sqlite_version
120     versions['sqlite'] = sqlite_version()
121 jonathan 1322 versions['sqlite-tuple'] = make_tuple(sqlite_version())
122 jonathan 1306
123     # GDAL
124     from Thuban.Model.resource import has_gdal_support
125     if has_gdal_support():
126     from gdalwarp import get_gdal_version
127     versions['gdal'] = get_gdal_version()
128 jonathan 1322 versions['gdal-tuple'] = make_tuple(get_gdal_version())
129 jonathan 1306
130 bh 2088 from wxproj import get_proj_version, get_gtk_version, get_wx_version
131 jonathan 1306
132     # GTK
133     gtk_ver = get_gtk_version()
134     if gtk_ver:
135     versions['gtk'] = ".".join(map(str, gtk_ver))
136     versions['gtk-tuple'] = gtk_ver
137    
138     # PROJ
139     proj_ver = get_proj_version()
140     if proj_ver:
141     versions['proj'] = ".".join(map(str, proj_ver))
142     versions['proj-tuple'] = proj_ver
143    
144 bh 2088 wxproj_wx_version = get_wx_version()
145     versions['wxproj-wx'] = ".".join(map(str, wxproj_wx_version))
146     versions['wxproj-wx-tuple'] = wxproj_wx_version
147    
148    
149 bh 1631 # psycopg/postgis
150     import Thuban.Model.postgisdb
151     if Thuban.Model.postgisdb.has_postgis_support():
152     v = Thuban.Model.postgisdb.psycopg_version()
153     versions['psycopg'] = v
154     versions['psycopg-tuple'] = make_tuple(v)
155    
156 jonathan 1306 def verify_versions():
157 bh 2088 """Verify that Thuban is using the correct versions of libraries.
158 jonathan 1306
159     Returns a non-empty list of strings indicating which libraries
160     are wrong, or the empty list if everthing is ok.
161     """
162    
163     #
164     # The 'name' below must correspong to an mapping in 'versions'.
165     # There must also exist a 'name'-tuple mapping.
166     #
167     # title name version
168     list = [["Python", "python", (2, 2, 1)],
169 jonathan 1322 ["wxPython", "wxPython", (2, 4, 0)],
170 jonathan 1319 ["SQLite", "sqlite", (2, 8, 0)],
171     ["PySQLite", "pysqlite", (0, 4, 1)],
172 jonathan 1306 ["PROJ", "proj", (4, 4, 5)],
173     ["GTK", "gtk", (1, 2, 3)],
174 jonathan 1322 ["GDAL", "gdal", (1, 1, 8)]]
175 jonathan 1306
176     errors = []
177     for title, name, version in list:
178     tup = versions.get("%s-tuple" % name, None)
179     if tup and tup < version:
180     errors.append(_("%s %s < %s") % \
181 bh 2088 (title, versions[name], ".".join(map(str, version))))
182 jonathan 1306
183 bh 2088 # Check whether the wxWindows version of wxPython and thuban's
184     # wxproj module match. If they don't match, segfaults are likely.
185     if versions["wxproj-wx-tuple"] != versions["wxPython-tuple"][:3]:
186     errors.append(_("Thuban was compiled with wx %(wxproj-wx)s"
187     " but wxPython is %(wxPython)s")
188     % versions)
189    
190 jonathan 1306 return errors
191 bh 2088
192 frank 922 if __name__ == "__main__":
193     print longversion
194 jonathan 1306

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26