Commit 3da50156 authored by Andrew Gibiansky's avatar Andrew Gibiansky

fixing --ipython flag, closes #178

parent e29336d8
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -708,7 +708,7 @@ evalCommand output (Expression expr) state = do
useDisplay displayExpr = do
-- If there are instance matches, convert the object into
-- a Display. We also serialize it into a bytestring. We get
-- the bytestring as a dynamic and then convert back to
-- the bytestring IO action as a dynamic and then convert back to
-- a bytestring, which we promptly unserialize. Note that
-- attempting to do this without the serialization to binary and
-- back gives very strange errors - all the types match but it
......
......@@ -37,6 +37,7 @@ import IHaskell.Types
data WhichIPython
= DefaultIPython -- ^ Use the one that IHaskell tries to install.
| ExplicitIPython String -- ^ Use the command-line flag provided one.
deriving Eq
-- | Which commit of IPython we are on.
ipythonCommit :: Text
......@@ -51,17 +52,21 @@ ipython :: WhichIPython -- ^ Which IPython to use (user-provided or IHaskell-ins
-> Bool -- ^ Whether to suppress output.
-> [Text] -- ^ IPython command line arguments.
-> Sh String -- ^ IPython output.
ipython which suppress args = do
runCmd <- liftIO $ Paths.getDataFileName "installation/run.sh"
venv <- fpToText <$> ipythonDir
let cmdArgs = [pack runCmd, venv] ++ args
-- We have this because `silently` in shelly < 1.4 does not silence
-- stderr. In shelly 1.4, however, using `run` does not let us use stdin,
-- and the current code breaks for unknown reasons. When the bug
-- https://github.com/yesodweb/Shelly.hs/issues/54
-- is closed, we should edit ihaskell.cabal to allow shelly 1.4.
runHandles "bash" cmdArgs handles doNothing
ipython which suppress args
| which == DefaultIPython = do
runCmd <- liftIO $ Paths.getDataFileName "installation/run.sh"
venv <- fpToText <$> ipythonDir
let cmdArgs = [pack runCmd, venv] ++ args
-- We have this because `silently` in shelly < 1.4 does not silence
-- stderr. In shelly 1.4, however, using `run` does not let us use stdin,
-- and the current code breaks for unknown reasons. When the bug
-- https://github.com/yesodweb/Shelly.hs/issues/54
-- is closed, we should edit ihaskell.cabal to allow shelly 1.4.
runHandles "bash" cmdArgs handles doNothing
| otherwise = do
let ExplicitIPython exe = which
runHandles (fpFromString exe) args handles doNothing
where handles = [InHandle Inherit, outHandle suppress, errorHandle suppress]
outHandle True = OutHandle CreatePipe
outHandle False = OutHandle Inherit
......
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