~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Wouter van Heyst
  • Date: 2005-10-28 20:30:32 UTC
  • mto: (1185.16.143)
  • mto: This revision was merged to the branch mainline in revision 1498.
  • Revision ID: larstiq@larstiq.dyndns.org-20051028203032-94a016293d15f207
Add reinvocation code to ensure setup.py is run by python2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# './setup.py install', or
5
5
# './setup.py --help' for more options
6
6
 
 
7
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
 
8
# including bzrlib.help
 
9
 
 
10
import os, sys
 
11
 
 
12
try:
 
13
    version_info = sys.version_info
 
14
except AttributeError:
 
15
    version_info = 1, 5 # 1.5 or older
 
16
 
 
17
REINVOKE = "__BZR_REINVOKE"
 
18
NEED_VERS = (2, 4)
 
19
KNOWN_PYTHONS = ('python2.4',)
 
20
 
 
21
if version_info < NEED_VERS:
 
22
    if not os.environ.has_key(REINVOKE):
 
23
        # mutating os.environ doesn't work in old Pythons
 
24
        os.putenv(REINVOKE, "1")
 
25
        for python in KNOWN_PYTHONS:
 
26
            try:
 
27
                os.execvp(python, [python] + sys.argv)
 
28
            except OSError:
 
29
                pass
 
30
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
31
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
 
32
    sys.exit(1)
 
33
if hasattr(os, "unsetenv"):
 
34
    os.unsetenv(REINVOKE)
 
35
 
 
36
 
7
37
from distutils.core import setup
8
38
from distutils.command.install_scripts import install_scripts
9
39
from distutils.command.build import build
10
40
 
11
 
 
12
41
###############################
13
42
# Overridden distutils actions
14
43
###############################