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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1993 - (show annotations)
Fri Nov 28 16:43:48 2003 UTC (21 years, 3 months ago) by bh
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 4524 byte(s)
(longversion): Update to 1.0rc1

1 # Copyright (C) 2002, 2003 by Intevation GmbH
2 # 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 version = 'cvs'
19 append_date = 1
20
21
22 import sys, os, os.path
23 import time
24 from string import split
25
26 from Thuban import _
27
28
29 if __name__ == "__main__":
30 import sys
31 __file__ = sys.argv[0]
32
33 def is_relevant_file(file):
34 """check if a file is relevant for determining the current version"""
35 extensions = ['.py', '.xpm', '.c', '.h']
36 return os.path.isfile(file) and os.path.splitext(file)[1] in extensions
37
38 def visit(args, dirname, names):
39 """helper for os.path.walk; save mtime of newest file for this directory"""
40 files = filter(is_relevant_file,
41 [os.path.join(dirname, file) for file in names])
42 args['max'] = max([args['max']] + map(os.path.getmtime, files))
43
44 def get_date(format):
45 """strftime formatted mtime of the newest relevant file"""
46 dir = os.path.dirname(os.path.abspath(__file__))
47 args = {'max': 0}
48 os.path.walk(dir, visit, args)
49 return time.strftime(format, time.localtime(args['max']))
50
51 def get_changelog_date():
52 changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")
53 try:
54 file = open(changelog, "r")
55 line = file.readline()
56 file.close()
57 except:
58 return ""
59 return 'ChangeLog %s' % line.split(" ")[0]
60
61
62 #
63 # Fill in versions with the different versions of the libraries
64 # that Thuban is using or requires (only if those libraries are
65 # available.
66 #
67
68 versions = {}
69
70 if append_date:
71 version = '%s-%s' % (version, get_date('%Y%m%d'))
72 versions['thuban'] = version
73
74 #longversion = '%s\n%s' % (version, get_changelog_date())
75 longversion = 'Release Version 1.0rc1'
76 versions['thuban-long'] = longversion
77
78 def make_tuple(s):
79 return tuple(map(int, split(s, ".")[:3]))
80
81 # wxPython
82 from wxPython.wx import __version__ as wxPython_version
83 versions['wxPython'] = wxPython_version
84 versions['wxPython-tuple'] = make_tuple(wxPython_version)
85
86 # Python
87 versions['python'] = "%d.%d.%d" % sys.version_info[:3]
88 versions['python-tuple'] = sys.version_info[:3]
89
90 # PySQLite
91 from sqlite import version as pysqlite_version
92 versions['pysqlite'] = pysqlite_version
93 versions['pysqlite-tuple'] = make_tuple(pysqlite_version)
94
95 # SQLite
96 from _sqlite import sqlite_version
97 versions['sqlite'] = sqlite_version()
98 versions['sqlite-tuple'] = make_tuple(sqlite_version())
99
100 # GDAL
101 from Thuban.Model.resource import has_gdal_support
102 if has_gdal_support():
103 from gdalwarp import get_gdal_version
104 versions['gdal'] = get_gdal_version()
105 versions['gdal-tuple'] = make_tuple(get_gdal_version())
106
107 from wxproj import get_proj_version, get_gtk_version
108
109 # GTK
110 gtk_ver = get_gtk_version()
111 if gtk_ver:
112 versions['gtk'] = ".".join(map(str, gtk_ver))
113 versions['gtk-tuple'] = gtk_ver
114
115 # PROJ
116 proj_ver = get_proj_version()
117 if proj_ver:
118 versions['proj'] = ".".join(map(str, proj_ver))
119 versions['proj-tuple'] = proj_ver
120
121 # psycopg/postgis
122 import Thuban.Model.postgisdb
123 if Thuban.Model.postgisdb.has_postgis_support():
124 v = Thuban.Model.postgisdb.psycopg_version()
125 versions['psycopg'] = v
126 versions['psycopg-tuple'] = make_tuple(v)
127
128 def verify_versions():
129 """Verifies that the versions of the libraries Thuban requires
130 are correct.
131
132 Returns a non-empty list of strings indicating which libraries
133 are wrong, or the empty list if everthing is ok.
134 """
135
136 #
137 # The 'name' below must correspong to an mapping in 'versions'.
138 # There must also exist a 'name'-tuple mapping.
139 #
140 # title name version
141 list = [["Python", "python", (2, 2, 1)],
142 ["wxPython", "wxPython", (2, 4, 0)],
143 ["SQLite", "sqlite", (2, 8, 0)],
144 ["PySQLite", "pysqlite", (0, 4, 1)],
145 ["PROJ", "proj", (4, 4, 5)],
146 ["GTK", "gtk", (1, 2, 3)],
147 ["GDAL", "gdal", (1, 1, 8)]]
148
149 errors = []
150 for title, name, version in list:
151 tup = versions.get("%s-tuple" % name, None)
152 if tup and tup < version:
153 errors.append(_("%s %s < %s") % \
154 (title, versions[name], ".".join(map(str, version))))
155
156 return errors
157
158 if __name__ == "__main__":
159 print longversion
160

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26