/[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 1480 - (hide annotations)
Thu Jul 24 17:52:48 2003 UTC (21 years, 7 months ago) by bh
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 4302 byte(s)
Remove the #! line as
it annoys lintian which warns about these files not being
executable. The #1 isn't necessary here since if you absolutely
must execute them you can always say "python <filename>".

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    
28    
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     longversion = 'Release Version 0.8.1'
76 jonathan 1306 versions['thuban-long'] = longversion
77    
78 jonathan 1322 def make_tuple(s):
79     return tuple(map(int, split(s, ".")[:3]))
80    
81 jonathan 1306 # wxPython
82     from wxPython.wx import __version__ as wxPython_version
83     versions['wxPython'] = wxPython_version
84 jonathan 1322 versions['wxPython-tuple'] = make_tuple(wxPython_version)
85 jonathan 1306
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 jonathan 1322 versions['pysqlite-tuple'] = make_tuple(pysqlite_version)
94 jonathan 1306
95     # SQLite
96     from _sqlite import sqlite_version
97     versions['sqlite'] = sqlite_version()
98 jonathan 1322 versions['sqlite-tuple'] = make_tuple(sqlite_version())
99 jonathan 1306
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 jonathan 1322 versions['gdal-tuple'] = make_tuple(get_gdal_version())
106 jonathan 1306
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     def verify_versions():
122     """Verifies that the versions of the libraries Thuban requires
123     are correct.
124    
125     Returns a non-empty list of strings indicating which libraries
126     are wrong, or the empty list if everthing is ok.
127     """
128    
129     #
130     # The 'name' below must correspong to an mapping in 'versions'.
131     # There must also exist a 'name'-tuple mapping.
132     #
133     # title name version
134     list = [["Python", "python", (2, 2, 1)],
135 jonathan 1322 ["wxPython", "wxPython", (2, 4, 0)],
136 jonathan 1319 ["SQLite", "sqlite", (2, 8, 0)],
137     ["PySQLite", "pysqlite", (0, 4, 1)],
138 jonathan 1306 ["PROJ", "proj", (4, 4, 5)],
139     ["GTK", "gtk", (1, 2, 3)],
140 jonathan 1322 ["GDAL", "gdal", (1, 1, 8)]]
141 jonathan 1306
142     errors = []
143     for title, name, version in list:
144     tup = versions.get("%s-tuple" % name, None)
145     if tup and tup < version:
146     errors.append(_("%s %s < %s") % \
147     (title, versions[name], ".".join(map(str, version))))
148    
149     return errors
150    
151 frank 922 if __name__ == "__main__":
152     print longversion
153 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