Commit 4df808fe authored by Andrew Gibiansky's avatar Andrew Gibiansky

Support for ipython 4

parent 801d35b4
...@@ -143,9 +143,9 @@ bindLocalEphemeralPort socket = do ...@@ -143,9 +143,9 @@ bindLocalEphemeralPort socket = do
-- The sockets will be closed when the callback returns. -- The sockets will be closed when the callback returns.
withEphemeralPorts :: ByteString -- ^ HMAC encryption key withEphemeralPorts :: ByteString -- ^ HMAC encryption key
-> Bool -- ^ Print debug output -> Bool -- ^ Print debug output
-> (ZeroMQEphemeralPorts -> ZeroMQInterface -> IO a) -- ^ Callback that takes the -> (ZeroMQEphemeralPorts
-- interface to the -> ZeroMQInterface
-- sockets. -> IO a) -- ^ Callback that takes the interface to the sockets.
-> IO a -> IO a
withEphemeralPorts key debug callback = do withEphemeralPorts key debug callback = do
channels <- newZeroMQInterface key channels <- newZeroMQInterface key
......
...@@ -69,7 +69,7 @@ ipython suppress args = do ...@@ -69,7 +69,7 @@ ipython suppress args = do
liftIO $ installHandler keyboardSignal (CatchOnce $ return ()) Nothing liftIO $ installHandler keyboardSignal (CatchOnce $ return ()) Nothing
-- We have this because using `run` does not let us use stdin. -- We have this because using `run` does not let us use stdin.
SH.runHandles "ipython" args handles doNothing SH.runHandles "jupyter" args handles doNothing
where where
handles = [SH.InHandle SH.Inherit, outHandle suppress, errorHandle suppress] handles = [SH.InHandle SH.Inherit, outHandle suppress, errorHandle suppress]
...@@ -128,18 +128,25 @@ replaceIPythonKernelspec kernelSpecOpts = SH.shelly $ do ...@@ -128,18 +128,25 @@ replaceIPythonKernelspec kernelSpecOpts = SH.shelly $ do
-- | Verify that a proper version of IPython is installed and accessible. -- | Verify that a proper version of IPython is installed and accessible.
verifyIPythonVersion :: SH.Sh () verifyIPythonVersion :: SH.Sh ()
verifyIPythonVersion = do verifyIPythonVersion = do
pathMay <- SH.which "ipython" pathMay <- SH.which "jupyter"
case pathMay of pathMay' <- SH.which "ipython"
Nothing -> badIPython "No IPython detected -- install IPython 3.0+ before using IHaskell." case (pathMay, pathMay') of
Just path -> do (Nothing, Nothing) -> badIPython "No Jupyter detected -- install Jupyter 3.0+ before using IHaskell."
output <- T.unpack <$> SH.silently (SH.run path ["--version"]) (Just path, _) -> do
SH.silently (SH.run path ["--version"])
output <- T.unpack <$> SH.lastStderr
case parseVersion output of case parseVersion output of
Just (4:_) -> return () Just (4:_) -> return ()
Just (3:_) -> return () Just (3:_) -> return ()
Just (2:_) -> oldIPython Just (2:_) -> oldIPython
Just (1:_) -> oldIPython Just (1:_) -> oldIPython
Just (0:_) -> oldIPython Just (0:_) -> oldIPython
_ -> badIPython "Detected IPython, but could not parse version number." _ -> badIPython "Detected Jupyter, but could not parse version number."
(_, Just path) -> do
output <- T.unpack <$> SH.silently (SH.run path ["--version"])
case parseVersion output of
Just (x:_) -> if x >= 3 then return () else oldIPython
_ -> badIPython "Detected Jupyter, but could not parse version number."
where where
badIPython :: Text -> SH.Sh () badIPython :: Text -> SH.Sh ()
......
...@@ -37,4 +37,4 @@ extra-deps: ...@@ -37,4 +37,4 @@ extra-deps:
- system-argv0-0.1.1 - system-argv0-0.1.1
- vinyl-0.5.1 - vinyl-0.5.1
- xformat-0.1.2.1 - xformat-0.1.2.1
resolver: nightly-2015-08-10 resolver: nightly-2015-08-15
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment