Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
36de4c2b
Commit
36de4c2b
authored
May 26, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of system-filepath
parent
e75e4463
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
27 deletions
+32
-27
ihaskell.cabal
ihaskell.cabal
+0
-2
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+1
-2
IPython.hs
src/IHaskell/IPython.hs
+31
-23
No files found.
ihaskell.cabal
View file @
36de4c2b
...
@@ -83,7 +83,6 @@ library
...
@@ -83,7 +83,6 @@ library
stm -any,
stm -any,
strict >=0.3,
strict >=0.3,
system-argv0 -any,
system-argv0 -any,
system-filepath -any,
text >=0.11,
text >=0.11,
transformers -any,
transformers -any,
unix >= 2.6,
unix >= 2.6,
...
@@ -193,7 +192,6 @@ Test-Suite hspec
...
@@ -193,7 +192,6 @@ Test-Suite hspec
stm -any,
stm -any,
strict >=0.3,
strict >=0.3,
system-argv0 -any,
system-argv0 -any,
system-filepath -any,
text >=0.11,
text >=0.11,
http-client == 0.4.*,
http-client == 0.4.*,
http-client-tls == 0.2.*,
http-client-tls == 0.2.*,
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
36de4c2b
{-# LANGUAGE No
ImplicitPrelude, DoAndIfThenElse, No
OverloadedStrings, TypeSynonymInstances, GADTs, CPP #-}
{-# LANGUAGE NoOverloadedStrings, TypeSynonymInstances, GADTs, CPP #-}
{- | Description : Wrapper around GHC API, exposing a single `evaluate` interface that runs
{- | Description : Wrapper around GHC API, exposing a single `evaluate` interface that runs
a statement, declaration, import, or directive.
a statement, declaration, import, or directive.
...
@@ -33,7 +33,6 @@ import Data.Dynamic
...
@@ -33,7 +33,6 @@ import Data.Dynamic
import
Data.Typeable
import
Data.Typeable
import
qualified
Data.Serialize
as
Serialize
import
qualified
Data.Serialize
as
Serialize
import
System.Directory
import
System.Directory
import
Filesystem.Path.CurrentOS
(
encodeString
)
#
if
!
MIN_VERSION_base
(
4
,
8
,
0
)
#
if
!
MIN_VERSION_base
(
4
,
8
,
0
)
import
System.Posix.IO
(
createPipe
)
import
System.Posix.IO
(
createPipe
)
#
endif
#
endif
...
...
src/IHaskell/IPython.hs
View file @
36de4c2b
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DoAndIfThenElse #-}
-- | Description : Shell scripting wrapper using @Shelly@ for the @notebook@, and
-- | Description : Shell scripting wrapper using @Shelly@ for the @notebook@, and
-- @console@ commands.
-- @console@ commands.
...
@@ -23,10 +22,10 @@ import qualified Data.ByteString.Char8 as CBS
...
@@ -23,10 +22,10 @@ import qualified Data.ByteString.Char8 as CBS
import
Control.Concurrent
(
threadDelay
)
import
Control.Concurrent
(
threadDelay
)
import
System.Argv0
import
System.Argv0
import
System.Directory
import
qualified
Shelly
as
SH
import
qualified
Shelly
as
SH
import
qualified
Filesystem.Path.CurrentOS
as
FS
import
qualified
System.IO
as
IO
import
qualified
System.IO
as
IO
import
qualified
System.FilePath
as
FP
import
System.Directory
import
Data.List.Utils
(
split
)
import
Data.List.Utils
(
split
)
import
Data.String.Utils
(
rstrip
,
endswith
,
strip
,
replace
)
import
Data.String.Utils
(
rstrip
,
endswith
,
strip
,
replace
)
import
System.Exit
(
exitFailure
)
import
System.Exit
(
exitFailure
)
...
@@ -88,11 +87,11 @@ quietRun path args = SH.runHandles path args handles nothing
...
@@ -88,11 +87,11 @@ quietRun path args = SH.runHandles path args handles nothing
handles
=
[
SH
.
InHandle
SH
.
Inherit
,
SH
.
OutHandle
SH
.
CreatePipe
,
SH
.
ErrorHandle
SH
.
CreatePipe
]
handles
=
[
SH
.
InHandle
SH
.
Inherit
,
SH
.
OutHandle
SH
.
CreatePipe
,
SH
.
ErrorHandle
SH
.
CreatePipe
]
nothing
_
_
_
=
return
()
nothing
_
_
_
=
return
()
fp
::
FS
.
FilePath
->
FilePath
fp
::
SH
.
FilePath
->
FilePath
fp
=
T
.
unpack
.
SH
.
toTextIgnore
fp
=
T
.
unpack
.
SH
.
toTextIgnore
-- | Create the directory and return it.
-- | Create the directory and return it.
ensure
::
SH
.
Sh
FS
.
FilePath
->
SH
.
Sh
FS
.
FilePath
ensure
::
SH
.
Sh
SH
.
FilePath
->
SH
.
Sh
SH
.
FilePath
ensure
getDir
=
do
ensure
getDir
=
do
dir
<-
getDir
dir
<-
getDir
SH
.
mkdir_p
dir
SH
.
mkdir_p
dir
...
@@ -101,13 +100,13 @@ ensure getDir = do
...
@@ -101,13 +100,13 @@ ensure getDir = do
-- | Return the data directory for IHaskell.
-- | Return the data directory for IHaskell.
ihaskellDir
::
SH
.
Sh
FilePath
ihaskellDir
::
SH
.
Sh
FilePath
ihaskellDir
=
do
ihaskellDir
=
do
home
<-
maybe
(
error
"$HOME not defined."
)
FS
.
fromText
<$>
SH
.
get_env
"HOME"
home
<-
maybe
(
error
"$HOME not defined."
)
SH
.
fromText
<$>
SH
.
get_env
"HOME"
fp
<$>
ensure
(
return
(
home
SH
.</>
".ihaskell"
))
fp
<$>
ensure
(
return
(
home
SH
.</>
".ihaskell"
))
ipythonDir
::
SH
.
Sh
FS
.
FilePath
ipythonDir
::
SH
.
Sh
SH
.
FilePath
ipythonDir
=
ensure
$
(
SH
.</>
"ipython"
)
<$>
ihaskellDir
ipythonDir
=
ensure
$
(
SH
.</>
"ipython"
)
<$>
ihaskellDir
notebookDir
::
SH
.
Sh
FS
.
FilePath
notebookDir
::
SH
.
Sh
SH
.
FilePath
notebookDir
=
ensure
$
(
SH
.</>
"notebooks"
)
<$>
ihaskellDir
notebookDir
=
ensure
$
(
SH
.</>
"notebooks"
)
<$>
ihaskellDir
getIHaskellDir
::
IO
String
getIHaskellDir
::
IO
String
...
@@ -180,7 +179,7 @@ installKernelspec replace opts = void $ do
...
@@ -180,7 +179,7 @@ installKernelspec replace opts = void $ do
let
files
=
[
"kernel.js"
,
"logo-64x64.png"
]
let
files
=
[
"kernel.js"
,
"logo-64x64.png"
]
forM_
files
$
\
file
->
do
forM_
files
$
\
file
->
do
src
<-
liftIO
$
Paths
.
getDataFileName
$
"html/"
++
file
src
<-
liftIO
$
Paths
.
getDataFileName
$
"html/"
++
file
SH
.
cp
(
FS
.
fromText
$
T
.
pack
src
)
(
tmp
SH
.</>
kernelName
SH
.</>
file
)
SH
.
cp
(
SH
.
fromText
$
T
.
pack
src
)
(
tmp
SH
.</>
kernelName
SH
.</>
file
)
Just
ipython
<-
SH
.
which
"ipython"
Just
ipython
<-
SH
.
which
"ipython"
let
replaceFlag
=
[
"--replace"
|
replace
]
let
replaceFlag
=
[
"--replace"
|
replace
]
...
@@ -202,9 +201,9 @@ subHome path = SH.shelly $ do
...
@@ -202,9 +201,9 @@ subHome path = SH.shelly $ do
-- | Get the path to an executable. If it doensn't exist, fail with an error message complaining
-- | Get the path to an executable. If it doensn't exist, fail with an error message complaining
-- about it.
-- about it.
path
::
Text
->
SH
.
Sh
FS
.
FilePath
path
::
Text
->
SH
.
Sh
SH
.
FilePath
path
exe
=
do
path
exe
=
do
path
<-
SH
.
which
$
FS
.
fromText
exe
path
<-
SH
.
which
$
SH
.
fromText
exe
case
path
of
case
path
of
Nothing
->
do
Nothing
->
do
liftIO
$
putStrLn
$
"Could not find `"
++
T
.
unpack
exe
++
"` executable."
liftIO
$
putStrLn
$
"Could not find `"
++
T
.
unpack
exe
++
"` executable."
...
@@ -221,27 +220,36 @@ parseVersion versionStr =
...
@@ -221,27 +220,36 @@ parseVersion versionStr =
else
Nothing
else
Nothing
-- | Get the absolute path to this IHaskell executable.
-- | Get the absolute path to this IHaskell executable.
getIHaskellPath
::
SH
.
Sh
String
getIHaskellPath
::
SH
.
Sh
FilePath
getIHaskellPath
=
do
getIHaskellPath
=
do
-- Get the absolute filepath to the argument.
-- Get the absolute filepath to the argument.
f
<-
liftIO
getArgv0
f
<-
T
.
unpack
<$>
SH
.
toTextIgnore
<$>
liftIO
getArgv0
-- If we have an absolute path, that's the IHaskell we're interested in.
-- If we have an absolute path, that's the IHaskell we're interested in.
if
F
S
.
a
bsolute
f
if
F
P
.
isA
bsolute
f
then
return
$
FS
.
encodeString
f
then
return
f
else
else
-- Check whether this is a relative path, or just 'IHaskell' with $PATH resolution done by
-- Check whether this is a relative path, or just 'IHaskell' with $PATH resolution done by
-- the shell. If it's just 'IHaskell', use the $PATH variable to find where IHaskell lives.
-- the shell. If it's just 'IHaskell', use the $PATH variable to find where IHaskell lives.
if
F
S
.
filen
ame
f
==
f
if
F
P
.
takeFileN
ame
f
==
f
then
do
then
do
ihaskellPath
<-
SH
.
which
"ihaskell"
ihaskellPath
<-
SH
.
which
"ihaskell"
case
ihaskellPath
of
case
ihaskellPath
of
Nothing
->
error
"ihaskell not on $PATH and not referenced relative to directory."
Nothing
->
error
"ihaskell not on $PATH and not referenced relative to directory."
Just
path
->
return
$
FS
.
encodeString
path
Just
path
->
return
$
T
.
unpack
$
SH
.
toTextIgnore
path
else
do
else
liftIO
$
makeAbsolute
f
-- If it's actually a relative path, make it absolute.
cd
<-
liftIO
getCurrentDirectory
return
$
FS
.
encodeString
$
FS
.
decodeString
cd
SH
.</>
f
#
if
!
MIN_VERSION_directory
(
1
,
2
,
2
)
-- This is included in later versions of `directory`, but we cannot use
-- later versions because GHC library depends on a particular version of it.
makeAbsolute
::
FilePath
->
IO
FilePath
makeAbsolute
=
fmap
FP
.
normalise
.
absolutize
where
absolutize
path
-- avoid the call to `getCurrentDirectory` if we can
|
FP
.
isRelative
path
=
fmap
(
FP
.</>
path
)
getCurrentDirectory
|
otherwise
=
return
path
#
endif
getSandboxPackageConf
::
IO
(
Maybe
String
)
getSandboxPackageConf
::
IO
(
Maybe
String
)
getSandboxPackageConf
=
SH
.
shelly
$
do
getSandboxPackageConf
=
SH
.
shelly
$
do
...
@@ -252,7 +260,7 @@ getSandboxPackageConf = SH.shelly $ do
...
@@ -252,7 +260,7 @@ getSandboxPackageConf = SH.shelly $ do
else
do
else
do
let
pieces
=
split
"/"
myPath
let
pieces
=
split
"/"
myPath
sandboxDir
=
intercalate
"/"
$
takeWhile
(
/=
sandboxName
)
pieces
++
[
sandboxName
]
sandboxDir
=
intercalate
"/"
$
takeWhile
(
/=
sandboxName
)
pieces
++
[
sandboxName
]
subdirs
<-
map
fp
<$>
SH
.
ls
(
FS
.
fromText
$
T
.
pack
sandboxDir
)
subdirs
<-
map
fp
<$>
SH
.
ls
(
SH
.
fromText
$
T
.
pack
sandboxDir
)
let
confdirs
=
filter
(
endswith
(
"packages.conf.d"
::
String
))
subdirs
let
confdirs
=
filter
(
endswith
(
"packages.conf.d"
::
String
))
subdirs
case
confdirs
of
case
confdirs
of
[]
->
return
Nothing
[]
->
return
Nothing
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment