##// END OF EJS Templates
use CFRunLoop directly in `ipython kernel --pylab osx`...
use CFRunLoop directly in `ipython kernel --pylab osx` via matplotlib.backend_macosx.TimerMac, rather than Tk Fallback on Tk if matplotlib is < 1.1.0, which introduces the necessary Timer. This means that it still won't work on current EPD, which has X11-linked libtk and matplotlib 1.0.1, but at least it will display a warning explaining why. also remove caveat in docs that qtconsole doesn't work with native MacOSX, since it does on normal (non-EPD) installs. So this will work in more places, but still not in most common failure case (stock EPD) described in #640.

File last commit:

r4574:a8c54759
r4853:5942e2a1
Show More
syspathcontext.py
69 lines | 2.0 KiB | text/x-python | PythonLexer
# encoding: utf-8
"""
Context managers for adding things to sys.path temporarily.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2009 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
#-----------------------------------------------------------------------------
import sys
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class appended_to_syspath(object):
"""A context for appending a directory to sys.path for a second."""
def __init__(self, dir):
self.dir = dir
def __enter__(self):
if self.dir not in sys.path:
sys.path.append(self.dir)
self.added = True
else:
self.added = False
def __exit__(self, type, value, traceback):
if self.added:
try:
sys.path.remove(self.dir)
except ValueError:
pass
# Returning False causes any exceptions to be re-raised.
return False
class prepended_to_syspath(object):
"""A context for prepending a directory to sys.path for a second."""
def __init__(self, dir):
self.dir = dir
def __enter__(self):
if self.dir not in sys.path:
sys.path.insert(0,self.dir)
self.added = True
else:
self.added = False
def __exit__(self, type, value, traceback):
if self.added:
try:
sys.path.remove(self.dir)
except ValueError:
pass
# Returning False causes any exceptions to be re-raised.
return False