summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-04-19 18:58:30 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-04-19 18:58:30 +0000
commit8a31e29feafddc3c29bf1ca8ee378fb7b69c67b7 (patch)
treedcfeddc41b8e84dc49707e5b809ecbc91d6e9b83 /numpy
parent7ac6e2005976d03e25e723bacd59f27ad87e86dc (diff)
downloadnumpy-8a31e29feafddc3c29bf1ca8ee378fb7b69c67b7.tar.gz
New feature: interactively set sys.argv when setup.py is called without arguments. At the moment the feature only can show system/platform/fcompiler information..
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/core.py20
-rw-r--r--numpy/distutils/interactive.py65
2 files changed, 84 insertions, 1 deletions
diff --git a/numpy/distutils/core.py b/numpy/distutils/core.py
index 6f4ab007f..bdc55a8ab 100644
--- a/numpy/distutils/core.py
+++ b/numpy/distutils/core.py
@@ -1,4 +1,5 @@
+import sys
from distutils.core import *
try:
from setuptools import setup as old_setup
@@ -90,6 +91,11 @@ def _command_line_ok(_cache=[]):
def setup(**attr):
+ interactive = len(sys.argv)<=1
+ if interactive:
+ from interactive import interactive_sys_argv
+ sys.argv[:] = interactive_sys_argv(sys.argv)
+
cmdclass = numpy_cmdclass.copy()
new_attr = attr.copy()
@@ -150,7 +156,19 @@ def setup(**attr):
and not new_attr.has_key('headers'):
new_attr['headers'] = []
- return old_setup(**new_attr)
+ if interactive:
+ try:
+ r = old_setup(**new_attr)
+ except Exception, msg:
+ print '-'*72
+ print 'setup failed with:',msg
+ raw_input('Press ENTER to close the interactive session..')
+ raise msg
+ print '-'*72
+ raw_input('Press ENTER to close the interactive session..')
+ print '='*72
+ else:
+ return old_setup(**new_attr)
def _check_append_library(libraries, item):
import warnings
diff --git a/numpy/distutils/interactive.py b/numpy/distutils/interactive.py
new file mode 100644
index 000000000..89d3d5612
--- /dev/null
+++ b/numpy/distutils/interactive.py
@@ -0,0 +1,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
+