Skip to content

Commit

Permalink
Merge pull request #30 from akabe/feature/installer
Browse files Browse the repository at this point in the history
Improve installer
  • Loading branch information
akabe authored Jul 25, 2017
2 parents 5fb0533 + 68633ac commit c66acb5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
6 changes: 5 additions & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ Executable "ocaml-jupyter-kernel"
MainIs: JupyterMain.ml
BuildDepends: jupyter.kernel
CompiledObject: byte
DataFiles: kernel.json
DataFiles: ../setup.ml,
../setup.log,
../setup.data,
../kernelspec.sh,
kernel.json

##
## Sub-packages
Expand Down
6 changes: 2 additions & 4 deletions jupyter.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ homepage: "https://github.com/akabe/ocaml-jupyter"
bug-reports: "https://github.com/akabe/ocaml-jupyter/issues"
dev-repo: "https://github.com/akabe/ocaml-jupyter.git"

available: [ ocaml-version >= "4.02.3" ]
available: [ ocaml-version >= "4.02.0" ]
build: [
[ "ocaml" "setup.ml" "-configure"
"--prefix" prefix
Expand All @@ -23,9 +23,7 @@ install: [
[ "ocaml" "setup.ml" "-install" ]
]
remove: [
[ "./kernelspec.sh" "uninstall" ]
[ "ocamlfind" "remove" "jupyter" ]
[ "rm" "%{bin}%/ocaml-jupyter-kernel" ]
[ "sh" "-c" "cd %{share}%/ocaml-jupyter ; ocaml setup.ml -uninstall" ]
[ "rm" "-rf" "%{share}%/ocaml-jupyter" ]
]
depends: [
Expand Down
22 changes: 14 additions & 8 deletions kernelspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function check_user_mode() {

function get_ocaml_version() {
if type -p opam >/dev/null 2>/dev/null; then
opam switch show
opam config var switch
else
ocaml -vnum
fi
Expand Down Expand Up @@ -49,22 +49,28 @@ function install() {
install_flags+=" --user"
fi

if [[ "$install_kernel" == 'true' ]] && type -p jupyter >/dev/null 2>/dev/null; then
jupyter kernelspec install $install_flags "$datadir"
fi
if [[ "$install_kernel" == 'true' ]] && type jupyter >/dev/null 2>&1; then
jupyter kernelspec install $install_flags "$datadir"
fi
}

function uninstall() {
if type jupyter >/dev/null 2>&1; then
jupyter kernelspec remove "$KERNEL_NAME" -f
fi
}

OCAML_VERSION=$(get_ocaml_version | sed 's@[^0-9A-Za-z_\.+-]@_@g')
KERNEL_NAME="ocaml-jupyter-${OCAML_VERSION}"

case $1 in
create )
create $2
create $2
;;
install )
install $2 $3
;;
uninstall )
jupyter kernelspec remove "$KERNEL_NAME" -f || :
;;
uninstall )
uninstall
;;
esac
7 changes: 5 additions & 2 deletions notebooks/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
"source": [
"## jupyter.notebook\n",
"\n",
"`jupyter.notebook` provides a way to control Jupyter from OCaml REPL in a notebook. Foex example, you can dynamically generate HTML, markdown, and images."
"`jupyter.notebook` provides a way to control Jupyter from OCaml REPL in a notebook. For example, you can dynamically generate HTML, markdown, and images."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#require \"jupyter.notebook\""
Expand Down Expand Up @@ -126,6 +128,7 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],
Expand Down
15 changes: 11 additions & 4 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.10 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 6480bb5ca4e70d3dfaa3f30675a5de1a) *)
(* DO NOT EDIT (digest: 2585950dd0d719e4daec62eba1abdfec) *)
(*
Regenerated by OASIS v0.4.10
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -7707,7 +7707,14 @@ let setup_t =
}
];
bs_c_sources = [];
bs_data_files = [("kernel.json", None)];
bs_data_files =
[
("../setup.ml", None);
("../setup.log", None);
("../setup.data", None);
("../kernelspec.sh", None);
("kernel.json", None)
];
bs_findlib_extra_files = [];
bs_ccopt = [(OASISExpr.EBool true, [])];
bs_cclib = [(OASISExpr.EBool true, [])];
Expand Down Expand Up @@ -8324,15 +8331,15 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.10";
oasis_digest = Some "p?9\178X\184\254\139\183\003\254\243\205_\245\174";
oasis_digest = Some "\140!\005\242\183\031@\004\021\207W\138\248\219[G";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 8336 "setup.ml"
# 8343 "setup.ml"
let setup_t = BaseCompat.Compat_0_4.adapt_setup_t setup_t
open BaseCompat.Compat_0_4
(* OASIS_STOP *)
Expand Down

0 comments on commit c66acb5

Please sign in to comment.