Commit fe3bbf32 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Updated to new Shelly. Fixed Ctrl-C quitting issues.

parent 47e0bbec
...@@ -80,7 +80,7 @@ library ...@@ -80,7 +80,7 @@ library
parsec -any, parsec -any,
process >=1.1, process >=1.1,
random >=1.0, random >=1.0,
shelly ==1.3.* || >= 1.4.4.2, shelly ==1.5.*,
split >= 0.2, split >= 0.2,
strict >=0.3, strict >=0.3,
system-argv0 -any, system-argv0 -any,
...@@ -173,7 +173,7 @@ Test-Suite hspec ...@@ -173,7 +173,7 @@ Test-Suite hspec
process >=1.1, process >=1.1,
random >=1.0, random >=1.0,
setenv -any, setenv -any,
shelly ==1.3.* || >= 1.4.4.2, shelly ==1.5.*,
split >= 0.2, split >= 0.2,
strict >=0.3, strict >=0.3,
system-argv0 -any, system-argv0 -any,
......
This diff is collapsed.
# Empty. # Empty.
c = get_config() c = get_config()
c.TerminalIPythonApp.display_banner = False c.TerminalIPythonApp.display_banner = False
c.TerminalInteractiveShell.confirm_exit = False
...@@ -20,7 +20,7 @@ instance Show BrokenPackage where ...@@ -20,7 +20,7 @@ instance Show BrokenPackage where
show = packageID show = packageID
getBrokenPackages :: IO [String] getBrokenPackages :: IO [String]
getBrokenPackages = shellyNoDir $ do getBrokenPackages = shelly $ do
silently $ errExit False $ run "ghc-pkg" ["check"] silently $ errExit False $ run "ghc-pkg" ["check"]
checkOut <- lastStderr checkOut <- lastStderr
......
...@@ -32,6 +32,7 @@ import qualified Paths_ihaskell as Paths ...@@ -32,6 +32,7 @@ import qualified Paths_ihaskell as Paths
import qualified Codec.Archive.Tar as Tar import qualified Codec.Archive.Tar as Tar
import IHaskell.Types import IHaskell.Types
import System.Posix.Signals
-- | Which IPython to use. -- | Which IPython to use.
data WhichIPython data WhichIPython
...@@ -60,11 +61,9 @@ ipython which suppress args ...@@ -60,11 +61,9 @@ ipython which suppress args
-- If we have PYTHONDONTWRITEBYTECODE enabled, everything breaks. -- If we have PYTHONDONTWRITEBYTECODE enabled, everything breaks.
setenv "PYTHONDONTWRITEBYTECODE" "" setenv "PYTHONDONTWRITEBYTECODE" ""
-- We have this because `silently` in shelly < 1.4 does not silence liftIO $ installHandler keyboardSignal (CatchOnce $ return ()) Nothing
-- 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 -- We have this because using `run` does not let us use stdin.
-- 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 runHandles "bash" cmdArgs handles doNothing
| otherwise = do | otherwise = do
let ExplicitIPython exe = which let ExplicitIPython exe = which
...@@ -114,10 +113,10 @@ ipythonSourceDir :: Sh FilePath ...@@ -114,10 +113,10 @@ ipythonSourceDir :: Sh FilePath
ipythonSourceDir = ensure $ (</> "ipython-src") <$> ihaskellDir ipythonSourceDir = ensure $ (</> "ipython-src") <$> ihaskellDir
getIHaskellDir :: IO String getIHaskellDir :: IO String
getIHaskellDir = shellyNoDir $ fpToString <$> ihaskellDir getIHaskellDir = shelly $ fpToString <$> ihaskellDir
defaultConfFile :: IO (Maybe String) defaultConfFile :: IO (Maybe String)
defaultConfFile = shellyNoDir $ do defaultConfFile = shelly $ do
filename <- (</> "rc.hs") <$> ihaskellDir filename <- (</> "rc.hs") <$> ihaskellDir
exists <- test_f filename exists <- test_f filename
return $ if exists return $ if exists
...@@ -128,7 +127,7 @@ defaultConfFile = shellyNoDir $ do ...@@ -128,7 +127,7 @@ defaultConfFile = shellyNoDir $ do
-- Notebooks are searched in the current directory as well as the IHaskell -- Notebooks are searched in the current directory as well as the IHaskell
-- notebook directory (in that order). -- notebook directory (in that order).
nbconvert :: WhichIPython -> ViewFormat -> String -> IO () nbconvert :: WhichIPython -> ViewFormat -> String -> IO ()
nbconvert which fmt name = void . shellyNoDir $ do nbconvert which fmt name = void . shelly $ do
curdir <- pwd curdir <- pwd
nbdir <- notebookDir nbdir <- notebookDir
...@@ -157,7 +156,7 @@ nbconvert which fmt name = void . shellyNoDir $ do ...@@ -157,7 +156,7 @@ nbconvert which fmt name = void . shellyNoDir $ do
setupIPython :: WhichIPython -> IO () setupIPython :: WhichIPython -> IO ()
setupIPython (ExplicitIPython path) = do setupIPython (ExplicitIPython path) = do
exists <- shellyNoDir $ exists <- shelly $
test_f $ fromString path test_f $ fromString path
unless exists $ unless exists $
...@@ -172,7 +171,7 @@ setupIPython DefaultIPython = do ...@@ -172,7 +171,7 @@ setupIPython DefaultIPython = do
-- | Replace "~" with $HOME if $HOME is defined. -- | Replace "~" with $HOME if $HOME is defined.
-- Otherwise, do nothing. -- Otherwise, do nothing.
subHome :: String -> IO String subHome :: String -> IO String
subHome path = shellyNoDir $ do subHome path = shelly $ do
home <- unpack <$> fromMaybe "~" <$> get_env "HOME" home <- unpack <$> fromMaybe "~" <$> get_env "HOME"
return $ replace "~" home path return $ replace "~" home path
...@@ -217,12 +216,12 @@ runIHaskell which profile app args = void $ do ...@@ -217,12 +216,12 @@ runIHaskell which profile app args = void $ do
ipython which False $ map pack $ [app, "--profile", profile] ++ args ipython which False $ map pack $ [app, "--profile", profile] ++ args
runConsole :: WhichIPython -> InitInfo -> IO () runConsole :: WhichIPython -> InitInfo -> IO ()
runConsole which initInfo = void . shellyNoDir $ do runConsole which initInfo = void . shelly $ do
writeInitInfo initInfo writeInitInfo initInfo
runIHaskell which ipythonProfile "console" [] runIHaskell which ipythonProfile "console" []
runNotebook :: WhichIPython -> InitInfo -> Maybe String -> IO () runNotebook :: WhichIPython -> InitInfo -> Maybe String -> IO ()
runNotebook which initInfo maybeServeDir = void . shellyNoDir $ do runNotebook which initInfo maybeServeDir = void . shelly $ do
notebookDirStr <- fpToString <$> notebookDir notebookDirStr <- fpToString <$> notebookDir
let args = case maybeServeDir of let args = case maybeServeDir of
Nothing -> ["--notebook-dir", unpack notebookDirStr] Nothing -> ["--notebook-dir", unpack notebookDirStr]
...@@ -237,7 +236,7 @@ writeInitInfo info = do ...@@ -237,7 +236,7 @@ writeInitInfo info = do
liftIO $ writeFile filename $ show info liftIO $ writeFile filename $ show info
readInitInfo :: IO InitInfo readInitInfo :: IO InitInfo
readInitInfo = shellyNoDir $ do readInitInfo = shelly $ do
filename <- (</> ".last-arguments") <$> ihaskellDir filename <- (</> ".last-arguments") <$> ihaskellDir
read <$> liftIO (readFile filename) read <$> liftIO (readFile filename)
...@@ -245,7 +244,7 @@ readInitInfo = shellyNoDir $ do ...@@ -245,7 +244,7 @@ readInitInfo = shellyNoDir $ do
setupIPythonProfile :: WhichIPython setupIPythonProfile :: WhichIPython
-> String -- ^ IHaskell profile name. -> String -- ^ IHaskell profile name.
-> IO () -> IO ()
setupIPythonProfile which profile = shellyNoDir $ do setupIPythonProfile which profile = shelly $ do
-- Create the IPython profile. -- Create the IPython profile.
void $ ipython which True ["profile", "create", pack profile] void $ ipython which True ["profile", "create", pack profile]
...@@ -314,7 +313,7 @@ getIHaskellPath = do ...@@ -314,7 +313,7 @@ getIHaskellPath = do
return $ FS.encodeString $ FS.decodeString cd FS.</> f return $ FS.encodeString $ FS.decodeString cd FS.</> f
getSandboxPackageConf :: IO (Maybe String) getSandboxPackageConf :: IO (Maybe String)
getSandboxPackageConf = shellyNoDir $ do getSandboxPackageConf = shelly $ do
myPath <- getIHaskellPath myPath <- getIHaskellPath
let sandboxName = ".cabal-sandbox" let sandboxName = ".cabal-sandbox"
if not $ sandboxName`isInfixOf` myPath if not $ sandboxName`isInfixOf` myPath
...@@ -331,7 +330,7 @@ getSandboxPackageConf = shellyNoDir $ do ...@@ -331,7 +330,7 @@ getSandboxPackageConf = shellyNoDir $ do
-- | Check whether IPython is properly installed. -- | Check whether IPython is properly installed.
ipythonInstalled :: IO Bool ipythonInstalled :: IO Bool
ipythonInstalled = shellyNoDir $ do ipythonInstalled = shelly $ do
ipythonPath <- ipythonExePath DefaultIPython ipythonPath <- ipythonExePath DefaultIPython
test_f ipythonPath test_f ipythonPath
...@@ -339,12 +338,12 @@ ipythonInstalled = shellyNoDir $ do ...@@ -339,12 +338,12 @@ ipythonInstalled = shellyNoDir $ do
updateIPython :: IO () updateIPython :: IO ()
updateIPython = do updateIPython = do
updateScript <- Paths.getDataFileName "installation/update.sh" updateScript <- Paths.getDataFileName "installation/update.sh"
venv <- fpToText <$> shellyNoDir ipythonDir venv <- fpToText <$> shelly ipythonDir
runTmp updateScript [venv, ipythonCommit] runTmp updateScript [venv, ipythonCommit]
-- Remove the old IPython profile. -- Remove the old IPython profile.
-- A new one will be regenerated when it is needed. -- A new one will be regenerated when it is needed.
-- shellyNoDir $ removeIPythonProfile DefaultIPython ipythonProfile -- shelly $ removeIPythonProfile DefaultIPython ipythonProfile
-- | Install IPython from source. -- | Install IPython from source.
installIPython :: IO () installIPython :: IO ()
...@@ -355,13 +354,13 @@ installIPython = do ...@@ -355,13 +354,13 @@ installIPython = do
-- Set up the virtualenv. -- Set up the virtualenv.
virtualenvScript <- Paths.getDataFileName "installation/virtualenv.sh" virtualenvScript <- Paths.getDataFileName "installation/virtualenv.sh"
venvDir <- fpToText <$> shellyNoDir ipythonDir venvDir <- fpToText <$> shelly ipythonDir
runTmp virtualenvScript [venvDir] runTmp virtualenvScript [venvDir]
-- Set up Python depenencies. -- Set up Python depenencies.
installScript <- Paths.getDataFileName "installation/ipython.sh" installScript <- Paths.getDataFileName "installation/ipython.sh"
runTmp installScript [venvDir, ipythonCommit] runTmp installScript [venvDir, ipythonCommit]
runTmp script args = shellyNoDir $ withTmpDir $ \tmp -> do runTmp script args = shelly $ withTmpDir $ \tmp -> do
cd tmp cd tmp
run_ "bash" $ pack script: args run_ "bash" $ pack script: args
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