[PATCH] python version check
Fredrik Lundh
fredrik at pythonware.com
Fri Apr 15 22:25:09 BST 2005
> here's a patch for the bzr start script that checks the python version. if
> the current interpreter is older than 2.3, it attempts to hand control over
> to a more modern interpreter.
>
> this has been tested with 1.5.2 and newer.
>
> (feel free to improve the error message, btw)
>
> enjoy! /F
*** modified file 'bzr'
--- bzr
+++ bzr
@@ -17,9 +17,23 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import sys, bzrlib, bzrlib.commands
+import os, sys
+try:
+ version_info = sys.version_info
+except AttributeError:
+ version_info = 1, 5 # 1.5 or older
+
+if version_info < (2, 3):
+ for python in 'python2.4', 'python2.3':
+ try:
+ os.execvp(python, [python] + sys.argv)
+ except OSError:
+ pass
+ print "***", "cannot find a suitable python interpreter"
+ sys.exit(1)
+
+import bzrlib, bzrlib.commands
if __name__ == '__main__':
sys.exit(bzrlib.commands.main(sys.argv))
-
More information about the bazaar
mailing list