/[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 1322 - (show annotations)
Mon Jun 30 12:01:50 2003 UTC (21 years, 8 months ago) by jonathan
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 4326 byte(s)
(make_tuple): Takes a version string
        and splits it into a tuple of at most three integers.
        Used make_tuple() to make tuple versions of the version
        numbers.

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

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26