summaryrefslogtreecommitdiff
path: root/numpy/distutils/interactive.py
blob: 89d3d5612fc5fff6fdde9d6c399bc2e23ea07eb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

import os
import sys
from pprint import pformat

__all__ = ['interactive_sys_argv']

def show_information():
    print 'Python',sys.version
    for a in ['platform','prefix','byteorder','path']:
        print 'sys.%s = %s' % (a,pformat(getattr(sys,a)))
    if hasattr(os,'uname'):
        print 'system,node,release,version,machine = ',os.uname()    

def show_environ():
    for k,i in os.environ.items():
        print '  %s = %s' % (k, i)

def show_fortran_compilers():
    from fcompiler import show_fcompilers
    show_fcompilers({})

def show_tasks():
    print """\

Tasks: 
  i   - Show python/platform/machine information
  e   - Show environment information
  f   - Show Fortran compilers information
  c   - Continue with running setup
  q   - Quit setup script
    """

def interactive_sys_argv(argv):
    print '='*72
    print 'Starting interactive session'
    print '-'*72

    task_dict = {'i':show_information,
                 'e':show_environ,
                 'f':show_fortran_compilers}

    while 1:
        show_tasks()
        task = raw_input('Choose a task: ').lower()
        if task=='c': break
        if task=='q': sys.exit()
        for t in task:
            task_func = task_dict.get(t,None)
            if task_func is None:
                print 'Skipping task:',`t`
                continue
            print '-'*68
            try:
                task_func()
            except Exception,msg:
                print 'Failed running task %s: %s' % (task,msg)
                break
            print '-'*68
        print

    print '-'*72
    argv.append('--help-commands') # for testing
    return argv