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]> |
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.2" |
42 |
|
thuban_release = "0" |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
import sys, os, os.path |
import sys, os, os.path |
48 |
from string import split |
from string import split |
49 |
|
|
50 |
from Thuban import _ |
from Thuban import _ |
51 |
|
from Thuban.Lib.version import make_tuple |
52 |
|
|
53 |
if __name__ == "__main__": |
if __name__ == "__main__": |
54 |
import sys |
import sys |
91 |
|
|
92 |
versions = {} |
versions = {} |
93 |
|
|
94 |
if append_date: |
if thuban_release == "svn": |
95 |
version = '%s-%s' % (version, get_date('%Y%m%d')) |
version = '%s %s-%s' % (thuban_branch, thuban_release, get_date('%Y%m%d')) |
96 |
versions['thuban'] = version |
longversion = '%s\n%s' % (version, get_changelog_date()) |
97 |
|
else: |
98 |
|
version = thuban_branch + "." + thuban_release |
99 |
|
longversion = 'Release Version ' + version |
100 |
|
|
101 |
longversion = '%s\n%s' % (version, get_changelog_date()) |
versions['thuban'] = version |
|
#longversion = 'Release Version 0.8' |
|
102 |
versions['thuban-long'] = longversion |
versions['thuban-long'] = longversion |
103 |
|
|
104 |
# wxPython |
# wxPython |
105 |
from wxPython.wx import __version__ as wxPython_version |
|
106 |
|
from wx import __version__ as wxPython_version |
107 |
versions['wxPython'] = wxPython_version |
versions['wxPython'] = wxPython_version |
108 |
versions['wxPython-tuple'] = tuple(map(int, split(wxPython_version, "."))) |
versions['wxPython-tuple'] = make_tuple(wxPython_version) |
109 |
|
|
110 |
# Python |
# Python |
111 |
versions['python'] = "%d.%d.%d" % sys.version_info[:3] |
versions['python'] = "%d.%d.%d" % sys.version_info[:3] |
112 |
versions['python-tuple'] = sys.version_info[:3] |
versions['python-tuple'] = sys.version_info[:3] |
113 |
|
|
114 |
# PySQLite |
# PySQLite |
115 |
from sqlite import version as pysqlite_version |
try: |
116 |
versions['pysqlite'] = pysqlite_version |
from pysqlite2 import dbapi2 as sqlite |
117 |
versions['pysqlite-tuple'] = tuple(map(int, split(pysqlite_version, "."))) |
except ImportError: |
118 |
|
import sqlite |
119 |
|
versions['pysqlite'] = sqlite.version |
120 |
|
versions['pysqlite-tuple'] = make_tuple(sqlite.version) |
121 |
|
|
122 |
# SQLite |
# SQLite |
123 |
from _sqlite import sqlite_version |
try: |
124 |
versions['sqlite'] = sqlite_version() |
from pysqlite2._sqlite import sqlite_version |
125 |
versions['sqlite-tuple'] = tuple(map(int, split(sqlite_version(), "."))) |
versions['sqlite'] = sqlite_version |
126 |
|
versions['sqlite-tuple'] = make_tuple(sqlite_version) |
127 |
|
except ImportError: |
128 |
|
from _sqlite import sqlite_version |
129 |
|
versions['sqlite'] = sqlite_version() |
130 |
|
versions['sqlite-tuple'] = make_tuple(sqlite_version()) |
131 |
|
|
132 |
# GDAL |
# GDAL |
133 |
from Thuban.Model.resource import has_gdal_support |
from Thuban.Model.resource import has_gdal_support |
134 |
if has_gdal_support(): |
if has_gdal_support(): |
135 |
from gdalwarp import get_gdal_version |
from gdalwarp import get_gdal_version |
136 |
versions['gdal'] = get_gdal_version() |
versions['gdal'] = get_gdal_version() |
137 |
versions['gdal-tuple'] = tuple(map(int, split(get_gdal_version(), "."))) |
versions['gdal-tuple'] = make_tuple(get_gdal_version()) |
138 |
|
|
139 |
from wxproj import get_proj_version, get_gtk_version |
from wxproj import get_proj_version, get_gtk_version, get_wx_version |
140 |
|
|
141 |
# GTK |
# GTK |
142 |
gtk_ver = get_gtk_version() |
gtk_ver = get_gtk_version() |
150 |
versions['proj'] = ".".join(map(str, proj_ver)) |
versions['proj'] = ".".join(map(str, proj_ver)) |
151 |
versions['proj-tuple'] = proj_ver |
versions['proj-tuple'] = proj_ver |
152 |
|
|
153 |
|
wxproj_wx_version = get_wx_version() |
154 |
|
versions['wxproj-wx'] = ".".join(map(str, wxproj_wx_version)) |
155 |
|
versions['wxproj-wx-tuple'] = wxproj_wx_version |
156 |
|
|
157 |
|
|
158 |
|
# psycopg/postgis |
159 |
|
import Thuban.Model.postgisdb |
160 |
|
if Thuban.Model.postgisdb.has_postgis_support(): |
161 |
|
v = Thuban.Model.postgisdb.psycopg_version() |
162 |
|
versions['psycopg'] = v |
163 |
|
versions['psycopg-tuple'] = make_tuple(v) |
164 |
|
|
165 |
def verify_versions(): |
def verify_versions(): |
166 |
"""Verifies that the versions of the libraries Thuban requires |
"""Verify that Thuban is using the correct versions of libraries. |
|
are correct. |
|
167 |
|
|
168 |
Returns a non-empty list of strings indicating which libraries |
Returns a non-empty list of strings indicating which libraries |
169 |
are wrong, or the empty list if everthing is ok. |
are wrong, or the empty list if everthing is ok. |
175 |
# |
# |
176 |
# title name version |
# title name version |
177 |
list = [["Python", "python", (2, 2, 1)], |
list = [["Python", "python", (2, 2, 1)], |
178 |
["wxPython", "wxPython", (2, 4, 0, 0)], |
["wxPython", "wxPython", (2, 4, 0)], |
179 |
["SQLite", "sqlite", (2, 8, 3)], |
["SQLite", "sqlite", (2, 8, 0)], |
180 |
["PySQLite", "pysqlite", (0, 4, 3)], |
["PySQLite", "pysqlite", (0, 4, 1)], |
181 |
["PROJ", "proj", (4, 4, 5)], |
["PROJ", "proj", (4, 4, 5)], |
182 |
["GTK", "gtk", (1, 2, 3)], |
["GTK", "gtk", (1, 2, 3)], |
183 |
["GDAL", "gdal", (1, 1, 8, 0)]] |
["GDAL", "gdal", (1, 1, 8)]] |
184 |
|
|
185 |
errors = [] |
errors = [] |
186 |
for title, name, version in list: |
for title, name, version in list: |
187 |
tup = versions.get("%s-tuple" % name, None) |
tup = versions.get("%s-tuple" % name, None) |
188 |
if tup and tup < version: |
if tup and tup < version: |
189 |
errors.append(_("%s %s < %s") % \ |
errors.append(_("%s %s < %s") % \ |
190 |
(title, versions[name], ".".join(map(str, version)))) |
(title, versions[name], ".".join(map(str, version)))) |
191 |
|
|
192 |
|
# Check whether the wxWindows version of wxPython and thuban's |
193 |
|
# wxproj module match. If they don't match, segfaults are likely. |
194 |
|
if versions["wxproj-wx-tuple"] != versions["wxPython-tuple"][:3]: |
195 |
|
errors.append(_("Thuban was compiled with wx %(wxproj-wx)s" |
196 |
|
" but wxPython is %(wxPython)s") |
197 |
|
% versions) |
198 |
|
|
199 |
return errors |
return errors |
200 |
|
|
201 |
if __name__ == "__main__": |
if __name__ == "__main__": |
202 |
print longversion |
print longversion |
203 |
|
|