/[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 2011 - (hide annotations)
Wed Dec 3 09:46:27 2003 UTC (21 years, 3 months ago) by bh
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 4499 byte(s)
* Thuban/Lib/version.py: New. Module for version number
manipulations. The version of make_tuple here also deals better
with more unusual version number strings, such as e.g.
"1.2+cvs20031111"

* Thuban/version.py (make_tuple): Removed. It's now in
Thuban.Lib.version. Use that implementation instead.

* test/test_lib_version.py: New. Tests for Thuban/Lib/version.py

1 frank 922 # 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 jonathan 1306 import sys, os, os.path
23 frank 922 import time
24 jonathan 1306 from string import split
25 frank 922
26 jonathan 1306 from Thuban import _
27 bh 2011 from Thuban.Lib.version import make_tuple
28 jonathan 1306
29 frank 922 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 frank 925 try:
54     file = open(changelog, "r")
55     line = file.readline()
56     file.close()
57     except:
58     return ""
59 jonathan 1306 return 'ChangeLog %s' % line.split(" ")[0]
60 frank 922
61 jonathan 1306
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 frank 922 if append_date:
71     version = '%s-%s' % (version, get_date('%Y%m%d'))
72 jonathan 1306 versions['thuban'] = version
73 frank 922
74 jonathan 1317 #longversion = '%s\n%s' % (version, get_changelog_date())
75 bh 1993 longversion = 'Release Version 1.0rc1'
76 jonathan 1306 versions['thuban-long'] = longversion
77    
78     # wxPython
79     from wxPython.wx import __version__ as wxPython_version
80     versions['wxPython'] = wxPython_version
81 jonathan 1322 versions['wxPython-tuple'] = make_tuple(wxPython_version)
82 jonathan 1306
83     # Python
84     versions['python'] = "%d.%d.%d" % sys.version_info[:3]
85     versions['python-tuple'] = sys.version_info[:3]
86    
87     # PySQLite
88     from sqlite import version as pysqlite_version
89     versions['pysqlite'] = pysqlite_version
90 jonathan 1322 versions['pysqlite-tuple'] = make_tuple(pysqlite_version)
91 jonathan 1306
92     # SQLite
93     from _sqlite import sqlite_version
94     versions['sqlite'] = sqlite_version()
95 jonathan 1322 versions['sqlite-tuple'] = make_tuple(sqlite_version())
96 jonathan 1306
97     # GDAL
98     from Thuban.Model.resource import has_gdal_support
99     if has_gdal_support():
100     from gdalwarp import get_gdal_version
101     versions['gdal'] = get_gdal_version()
102 jonathan 1322 versions['gdal-tuple'] = make_tuple(get_gdal_version())
103 jonathan 1306
104     from wxproj import get_proj_version, get_gtk_version
105    
106     # GTK
107     gtk_ver = get_gtk_version()
108     if gtk_ver:
109     versions['gtk'] = ".".join(map(str, gtk_ver))
110     versions['gtk-tuple'] = gtk_ver
111    
112     # PROJ
113     proj_ver = get_proj_version()
114     if proj_ver:
115     versions['proj'] = ".".join(map(str, proj_ver))
116     versions['proj-tuple'] = proj_ver
117    
118 bh 1631 # psycopg/postgis
119     import Thuban.Model.postgisdb
120     if Thuban.Model.postgisdb.has_postgis_support():
121     v = Thuban.Model.postgisdb.psycopg_version()
122     versions['psycopg'] = v
123     versions['psycopg-tuple'] = make_tuple(v)
124    
125 jonathan 1306 def verify_versions():
126     """Verifies that the versions of the libraries Thuban requires
127     are correct.
128    
129     Returns a non-empty list of strings indicating which libraries
130     are wrong, or the empty list if everthing is ok.
131     """
132    
133     #
134     # The 'name' below must correspong to an mapping in 'versions'.
135     # There must also exist a 'name'-tuple mapping.
136     #
137     # title name version
138     list = [["Python", "python", (2, 2, 1)],
139 jonathan 1322 ["wxPython", "wxPython", (2, 4, 0)],
140 jonathan 1319 ["SQLite", "sqlite", (2, 8, 0)],
141     ["PySQLite", "pysqlite", (0, 4, 1)],
142 jonathan 1306 ["PROJ", "proj", (4, 4, 5)],
143     ["GTK", "gtk", (1, 2, 3)],
144 jonathan 1322 ["GDAL", "gdal", (1, 1, 8)]]
145 jonathan 1306
146     errors = []
147     for title, name, version in list:
148     tup = versions.get("%s-tuple" % name, None)
149     if tup and tup < version:
150     errors.append(_("%s %s < %s") % \
151     (title, versions[name], ".".join(map(str, version))))
152    
153     return errors
154    
155 frank 922 if __name__ == "__main__":
156     print longversion
157 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