##// END OF EJS Templates
python3 syntax fixes on various scripts...
python3 syntax fixes on various scripts revealed by running tools/build_relese

File last commit:

r16525:a15a6bb0
r20277:6ceb4492
Show More
setupext.py
177 lines | 5.2 KiB | text/x-python | PythonLexer
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 # encoding: utf-8
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 from __future__ import print_function
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237
__docformat__ = "restructuredtext en"
#-------------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
Spencer Nelson
Remove unused imports
r16525 import sys
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 from textwrap import fill
display_status=True
MinRK
make display_status optional at runtime in setupext...
r3744 def check_display(f):
"""decorator to allow display methods to be muted by mod.display_status"""
def maybe_display(*args, **kwargs):
if display_status:
return f(*args, **kwargs)
return maybe_display
@check_display
def print_line(char='='):
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 print(char * 76)
MinRK
make display_status optional at runtime in setupext...
r3744
@check_display
def print_status(package, status):
initial_indent = "%22s: " % package
indent = ' ' * 24
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 print(fill(str(status), width=76,
MinRK
make display_status optional at runtime in setupext...
r3744 initial_indent=initial_indent,
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 subsequent_indent=indent))
MinRK
make display_status optional at runtime in setupext...
r3744
@check_display
def print_message(message):
indent = ' ' * 24 + "* "
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 print(fill(str(message), width=76,
MinRK
make display_status optional at runtime in setupext...
r3744 initial_indent=indent,
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 subsequent_indent=indent))
MinRK
make display_status optional at runtime in setupext...
r3744
@check_display
def print_raw(section):
Thomas Kluyver
Make single setup script work on Python 2 and Python 3.
r5828 print(section)
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237
#-------------------------------------------------------------------------------
# Tests for specific packages
#-------------------------------------------------------------------------------
def check_for_ipython():
try:
import IPython
except ImportError:
print_status("IPython", "Not found")
return False
else:
print_status("IPython", IPython.__version__)
return True
def check_for_sphinx():
try:
import sphinx
except ImportError:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('sphinx', "Not found (required for docs and nbconvert)")
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return False
else:
Bernardo B. Marques
remove all trailling spaces
r4872 print_status('sphinx', sphinx.__version__)
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return True
def check_for_pygments():
try:
import pygments
except ImportError:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('pygments', "Not found (required for docs and nbconvert)")
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return False
else:
print_status('pygments', pygments.__version__)
return True
Brian E. Granger
Fixing install logic for nbconvert.
r11090 def check_for_jinja2():
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 try:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 import jinja2
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 except ImportError:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('jinja2', "Not found (required for notebook and nbconvert)")
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return False
else:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('jinja2', jinja2.__version__)
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return True
Brian E. Granger
Fixing install logic for nbconvert.
r11090 def check_for_nose():
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 try:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 import nose
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 except ImportError:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('nose', "Not found (required for running the test suite)")
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return False
else:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status('nose', nose.__version__)
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return True
Brian E. Granger
Fixing install logic for nbconvert.
r11090 def check_for_pexpect():
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 try:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 import pexpect
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 except ImportError:
MinRK
mention that pexpect ships in IPython.external...
r15026 print_status("pexpect", "no (will use bundled version in IPython.external)")
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return False
else:
Brian E. Granger
Fixing install logic for nbconvert.
r11090 print_status("pexpect", pexpect.__version__)
Brian E Granger
Initial work towards refactoring the setup.py scripts to accept the new ipython1 packages...
r1237 return True
MinRK
add scripts for non-setuptools install of zmq.parallel
r3634 def check_for_pyzmq():
try:
import zmq
except ImportError:
MinRK
fix pyzmq check in setupext to handle 2.1.10...
r5245 print_status('pyzmq', "no (required for qtconsole, notebook, and parallel computing capabilities)")
MinRK
add scripts for non-setuptools install of zmq.parallel
r3634 return False
else:
MinRK
fix pyzmq check in setupext to handle 2.1.10...
r5245 # pyzmq 2.1.10 adds pyzmq_version_info funtion for returning
# version as a tuple
MinRK
bump minimum pyzmq version to 2.1.11...
r9336 if hasattr(zmq, 'pyzmq_version_info') and zmq.pyzmq_version_info() >= (2,1,11):
MinRK
fix pyzmq check in setupext to handle 2.1.10...
r5245 print_status("pyzmq", zmq.__version__)
return True
MinRK
add scripts for non-setuptools install of zmq.parallel
r3634 else:
MinRK
bump minimum pyzmq version to 2.1.11...
r9336 print_status('pyzmq', "no (have %s, but require >= 2.1.11 for"
" qtconsole, notebook, and parallel computing capabilities)" % zmq.__version__)
return False
MinRK
add scripts for non-setuptools install of zmq.parallel
r3634
Paul Ivanov
added check_for_tornado, closes #3916...
r12000 def check_for_tornado():
try:
import tornado
except ImportError:
print_status('tornado', "no (required for notebook)")
return False
else:
MinRK
bump minimum tornado version to 3.1.0...
r13313 if getattr(tornado, 'version_info', (0,)) < (3,1):
print_status('tornado', "no (have %s, but require >= 3.1.0)" % tornado.version)
return False
else:
print_status('tornado', tornado.version)
return True
Paul Ivanov
added check_for_tornado, closes #3916...
r12000
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 def check_for_readline():
MinRK
add version checking to pyreadline import test...
r7526 from distutils.version import LooseVersion
MinRK
depend on new gnureadline instead of readline on OS X...
r15402 readline = None
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 try:
MinRK
depend on new gnureadline instead of readline on OS X...
r15402 import gnureadline as readline
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 except ImportError:
MinRK
depend on new gnureadline instead of readline on OS X...
r15402 pass
if readline is None:
try:
import readline
except ImportError:
pass
if readline is None:
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 try:
import pyreadline
MinRK
add version checking to pyreadline import test...
r7526 vs = pyreadline.release.version
except (ImportError, AttributeError):
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 print_status('readline', "no (required for good interactive behavior)")
return False
MinRK
add version checking to pyreadline import test...
r7526 if LooseVersion(vs).version >= [1,7,1]:
print_status('readline', "yes pyreadline-" + vs)
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 return True
MinRK
add version checking to pyreadline import test...
r7526 else:
print_status('readline', "no pyreadline-%s < 1.7.1" % vs)
return False
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 else:
MinRK
check for libedit in readline on OS X...
r13797 if sys.platform == 'darwin' and 'libedit' in readline.__doc__:
print_status('readline', "no (libedit detected)")
return False
MinRK
make readline a dependency on OSX and pyreadline on Windows...
r3699 print_status('readline', "yes")
return True