-
Notifications
You must be signed in to change notification settings - Fork 14
/
jupyternim.nimble
73 lines (63 loc) · 2.51 KB
/
jupyternim.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Package
version = "0.8.0"
author = "stisa"
description = "A Jupyter Kernel for Nim"
license = "MIT"
# Dependencies
requires "nim >= 1.2.0"
requires "zmq >= 1.2.1 & < 1.3.0"
requires "hmac >= 0.2.0 & < 0.3.0"
requires "nimSHA2#b8f666069dff1ed0c5142dd1ca692f0e71434716"
requires "nimPNG#2dccf3e19ceb3fdf3f3f415e717d9d336d473a19"
installDirs = @["jupyternimpkg", "jupyternimspec"]
srcDir = "src"
bin = @["jupyternim"]
import os, strutils
after install:
when defined(macosx) and defined(arm64):
# M1 Homebrew lives in /opt/homebrew; libzmq isn't in /usr/local.
# Setting DYLD_LIBRARY_PATH works in some cases, but macOS "SIP" nulls out
# DYLD_LIBRARY_PATH for some child procs (/bin/sh, /usr/bin/env). gorgeEx
# uses /bin/sh so running jupyternim from NimScript will fail to find
# libzmq.dylib.
echo "\nTo install Jupyter Nim kernel, run:\n"
echo " jupyternim\n"
else:
var jnpath = gorgeEx("nimble path jupyternim")
jnpath.output.stripLineEnd
if jnpath.exitCode == 0:
var path = jnpath.output.splitLines()[^1]
exec(path / bin[0].changeFileExt(ExeExt))
else:
echo "Error: jupyternim not installed in nimble"
task dev, "Build a debug version":
# Assumes cwd is jupyternim/
var jnpath = gorgeEx("nimble path jupyternim")
jnpath.output.stripLineEnd
if jnpath.exitCode == 0:
var path = jnpath.output.splitLines()[^1]
exec("nim c -d:debug -o:" & path / bin[0].changeFileExt(ExeExt) & " src/jupyternim.nim")
else:
echo "Can't find an installed jupyternim"
task hcr, "Build a debug version with -d:useHcr":
# Assumes cwd is jupyternim/
var jnpath = gorgeEx("nimble path jupyternim")
jnpath.output.stripLineEnd
if jnpath.exitCode == 0:
var path = jnpath.output.splitLines()[^1]
exec("nim c -d:debug -d:useHcr -o:" & path / bin[0].changeFileExt(ExeExt) & " src/jupyternim.nim")
else:
echo "Can't find an installed jupyternim"
task rhcr, "Build and register a release version with -d:useHcr":
# Assumes cwd is jupyternim/
var jnpath = gorgeEx("nimble path jupyternim")
jnpath.output.stripLineEnd
if jnpath.exitCode == 0:
var path = jnpath.output.splitLines()[^1]
exec("nim c -d:release -d:useHcr -o:" & path / bin[0].changeFileExt(ExeExt) & " src/jupyternim.nim")
exec(path / bin[0].changeFileExt(ExeExt))
else:
echo "Can't find an installed jupyternim"
task docs, "Build docs":
exec(r"nim doc -O:.\docs\display.html .\src\jupyternimpkg\display.nim")
exec(r"nim doc -O:.\docs\index.html .\src\jupyternim.nim")