From bafa847310455388f7db662c4d98807d0a97144b 2008-05-28 06:52:07 From: Fernando Perez Date: 2008-05-28 06:52:07 Subject: [PATCH] Merge --- diff --git a/IPython/Extensions/ipy_completers.py b/IPython/Extensions/ipy_completers.py index ecc724a..1e88db4 100644 --- a/IPython/Extensions/ipy_completers.py +++ b/IPython/Extensions/ipy_completers.py @@ -331,7 +331,29 @@ def cd_completer(self, event): if os.path.isdir(relpath): return [relpath] raise IPython.ipapi.TryNext - return found + + + def single_dir_expand(matches): + "Recursively expand match lists containing a single dir." + + if len(matches) == 1 and os.path.isdir(matches[0]): + # Takes care of links to directories also. Use '/' + # explicitly, even under Windows, so that name completions + # don't end up escaped. + d = matches[0] + if d[-1] in ['/','\\']: + d = d[:-1] + + subdirs = [p for p in os.listdir(d) if os.path.isdir( d + '/' + p)] + if subdirs: + matches = [ (d + '/' + p) for p in subdirs ] + return single_dir_expand(matches) + else: + return matches + else: + return matches + + return single_dir_expand(found) def apt_get_packages(prefix): out = os.popen('apt-cache pkgnames') diff --git a/IPython/Magic.py b/IPython/Magic.py index 19ac301..ccca61b 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -3148,13 +3148,13 @@ Defaulting color scheme to 'NoColor'""" The block is dedented prior to execution to enable execution of method definitions. '>' and '+' characters at the beginning of a line are - ignored, to allow pasting directly from e-mails or diff files. The - executed block is also assigned to variable named 'pasted_block' for + ignored, to allow pasting directly from e-mails, diff files and doctests. + The executed block is also assigned to variable named 'pasted_block' for later editing with '%edit pasted_block'. You can also pass a variable name as an argument, e.g. '%cpaste foo'. This assigns the pasted block to variable 'foo' as string, without - dedenting or executing it. + dedenting or executing it (preceding >>> and + is still stripped) Do not be alarmed by garbled output on Windows (it's a readline bug). Just press enter and type -- (and press enter again) and the block @@ -3167,7 +3167,7 @@ Defaulting color scheme to 'NoColor'""" sentinel = opts.get('s','--') strip_from_start = [re.compile(e) for e in - ['^(.?>)+','^In \[\d+\]:','^\++']] + [r'^\s*(\s?>)+',r'^\s*In \[\d+\]:',r'^\++']] from IPython import iplib lines = [] print "Pasting code; enter '%s' alone on the line to stop." % sentinel diff --git a/IPython/Release.py b/IPython/Release.py index 72e896e..c36d249 100644 --- a/IPython/Release.py +++ b/IPython/Release.py @@ -22,7 +22,7 @@ name = 'ipython' # because bdist_rpm does not accept dashes (an RPM) convention, and # bdist_deb does not accept underscores (a Debian convention). -revision = '109' +revision = '117' branch = 'ipython' if branch == 'ipython': @@ -30,6 +30,8 @@ if branch == 'ipython': else: version = '0.8.3.bzr.r%s.%s' % (revision,branch) +version = '0.8.3' + description = "An enhanced interactive Python shell." long_description = \ diff --git a/IPython/genutils.py b/IPython/genutils.py index 5b5f852..422f5c5 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -22,7 +22,10 @@ __license__ = Release.license # required modules from the Python standard library import __main__ import commands -import doctest +try: + import doctest +except ImportError: + pass import os import re import shlex diff --git a/IPython/iplib.py b/IPython/iplib.py index 03846f8..4355beb 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -702,7 +702,10 @@ class InteractiveShell(object,Magic): # Do a proper resetting of doctest, including the necessary displayhook # monkeypatching - doctest_reload() + try: + doctest_reload() + except ImportError: + warn("doctest module does not exist.") # Set user colors (don't do it in the constructor above so that it # doesn't crash if colors option is invalid) diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index e604feb..64ef629 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -103,9 +103,12 @@ def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1, embedded=embedded,**kw) # Put 'help' in the user namespace - from site import _Helper + try: + from site import _Helper + IP.user_ns['help'] = _Helper() + except ImportError: + warn('help() not available - check site.py') IP.user_config_ns = {} - IP.user_ns['help'] = _Helper() if DEVDEBUG: diff --git a/doc/ChangeLog b/doc/ChangeLog index 7d435ae..b29cf8c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,14 @@ +2008-05-27 Ville Vainio + + * iplib.py, ipmaker.py: survive lack of doctest and site._Helper + for minimal environments (e.g. Maemo sdk python) + + * Magic.py: cpaste strips whitespace before >>> (allow pasting + doctests) + + * ipy_completers.py: cd completer now does recursive path expand + (old behaviour is buggy on some readline versions) + 2008-05-14 Ville Vainio * Extensions/ipy_greedycompleter.py: diff --git a/doc/build_doc_instruction.txt b/doc/build_doc_instruction.txt deleted file mode 100644 index b546509..0000000 --- a/doc/build_doc_instruction.txt +++ /dev/null @@ -1,28 +0,0 @@ -How to generate IPython documentation -===================================== - -The doc is written using lyx http://www.lyx.org, which is a gui for latex -documents. LyX also requires a latex installation. - -The file manual_base.lyx is the template file that should be edited if you -want to do changes to the docs. - -A final version is generated by running - -./update_manual.py - -or - -ipython update_manual.py - -(note that "python update_manual.py" won't work, it's an ipython script!) - -The script update_manual.py will insert the current version number into the -template and also generate magic.tex, a file containing documentation for -the doc strings of the magic commands. - -The script creates manual.lyx which can be opened by lyx to generate pdf or -postscript versions of the docs. - -update_magic.sh and update_version.sh work too, but are slated for -deprecation. diff --git a/doc/update_magic.sh b/doc/update_magic.sh deleted file mode 100755 index 71098a8..0000000 --- a/doc/update_magic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ipython --magic_docstrings > magic.tex \ No newline at end of file diff --git a/doc/update_manual.py b/doc/update_manual.py deleted file mode 100644 index 2ab5e64..0000000 --- a/doc/update_manual.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env ipython -""" Must be launched via ipython not normal python - -Run by: - - ipython update_manual.py -""" - -import sys,IPython,re - -fil=open("magic.tex","w") -oldout=sys.stdout -sys.stdout=fil -_ip.magic("magic -latex") -sys.stdout=oldout -fil.close() - -fil=open("manual_base.lyx") -txt=fil.read() -fil.close() - -manualtext=re.sub("__version__",IPython.__version__,txt) -fil=open("manual.lyx","w") -fil.write(manualtext) -fil.close() -print "Manual (magic.tex, manual.lyx) succesfully updated, exiting..." -import os -os.abort() diff --git a/scripts/ipython_win_post_install.py b/scripts/ipython_win_post_install.py index 3349027..fa0ca53 100755 --- a/scripts/ipython_win_post_install.py +++ b/scripts/ipython_win_post_install.py @@ -60,11 +60,11 @@ def install(): mkshortcut(python,'IPython scipy profile',f,a) # Create documentation shortcuts ... - t = prefix + r'\share\doc\ipython-%s\manual.pdf' % version + t = prefix + r'\share\doc\ipython\manual\ipython.pdf' f = ip_dir + r'\Manual in PDF.lnk' mkshortcut(t,r'IPython Manual - PDF-Format',f) - t = prefix + r'\share\doc\ipython-%s\manual\manual.html' % version + t = prefix + r'\share\doc\ipython\manual\ipython.html' f = ip_dir + r'\Manual in HTML.lnk' mkshortcut(t,'IPython Manual - HTML-Format',f) diff --git a/test/test_cpaste.ipy b/test/test_cpaste.ipy index 90811f7..259e930 100644 --- a/test/test_cpaste.ipy +++ b/test/test_cpaste.ipy @@ -3,7 +3,8 @@ tests = {'pass': ["> > > run()", ">>> > run()", "+++ run()", - "++ run()"], + "++ run()", + " >>> run()"], 'fail': ["+ + run()", " ++ run()"]} diff --git a/tools/make_tarball.py b/tools/make_tarball.py index 7768bcd..84491b9 100755 --- a/tools/make_tarball.py +++ b/tools/make_tarball.py @@ -1,5 +1,6 @@ import os,sys,shutil + basever = '0.8.3' def oscmd(c): @@ -19,7 +20,7 @@ def verinfo(): basename = 'ipython' #tarname = '%s.r%s.tgz' % (basename, ver) -oscmd('update_revnum.py') +oscmd('python update_revnum.py') ver = verinfo() diff --git a/tools/mkrel.py b/tools/mkrel.py index 4d3b056..b4206d2 100755 --- a/tools/mkrel.py +++ b/tools/mkrel.py @@ -26,14 +26,25 @@ if os.path.isdir('dist'): if os.path.isdir(ipykit_name): distutils.dir_util.remove_tree(ipykit_name) -c("python exesetup.py py2exe") +if sys.platform == 'win32': + c("python exesetup.py py2exe") -os.rename('dist',ipykit_name) + os.rename('dist',ipykit_name) -c("zip -r %s.zip %s" % (ipykit_name, ipykit_name)) + c("zip -r %s.zip %s" % (ipykit_name, ipykit_name)) + +# Build source and binary distros +c('./setup.py sdist --formats=gztar') + +c("python2.4 ./setup.py bdist_rpm --binary-only --release=py24 --python=/usr/bin/python2.4") +c("python2.5 ./setup.py bdist_rpm --binary-only --release=py25 --python=/usr/bin/python2.5") + +# Build eggs +c('python2.4 ./eggsetup.py bdist_egg') +c('python2.5 ./eggsetup.py bdist_egg') c("python setup.py bdist_wininst --install-script=ipython_win_post_install.py") -os.chdir("dist") -#c("svn export http://ipython.scipy.org/svn/ipython/ipython/trunk ipython") -#c("zip -r ipython_svn.zip ipython") +os.chdir('tools') +c('python make_tarball.py') +