forked from sebasguts/jupyter_kernel_singular
/
setup.py
56 lines (45 loc) · 1.92 KB
/
setup.py
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
#!/usr/bin/env python
from glob import glob
from distutils.core import setup
from setuptools.command.install import install as _install
import json
import os
import sys
from jupyter_client.kernelspec import install_kernel_spec
from IPython.utils.tempdir import TemporaryDirectory
from os.path import dirname,abspath
from shutil import copy as file_copy
kernelpath = os.path.join("share", "jupyter", "kernels", "singular")
nbextpath = os.path.join("share", "jupyter", "nbextensions", "singular-mode")
kernel_json = {"argv":[sys.executable,"-m","jupyter_kernel_singular", "-f", "{connection_file}"],
"display_name":"Singular",
"language":"singular",
"codemirror_mode":"singular",
"env":{"PS1": "$"}
}
class install(_install):
def run(self):
from notebook.nbextensions import enable_nbextension
# run from distutils install
_install.run(self)
#install kernel specs
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
print('Installing IPython kernel spec')
install_kernel_spec(td, 'Singular', user=self.user, replace=True)
# enable codemirror notebook extension
enable_nbextension('notebook', 'singular-mode/main')
setup( name="jupyter_kernel_singular"
, version="0.9.6"
, description="A Jupyter kernel for singular"
, author="Sebastian Gutsche"
, author_email="sebastian.gutsche@gmail.com"
, url="https://github.com/sebasguts/jupyter-singular"
, packages=["jupyter_kernel_singular"]
, package_dir={"jupyter_kernel_singular": "jupyter_kernel_singular"}
, data_files=[(kernelpath, glob("jupyter_kernel_singular/resources/*")),
(nbextpath, glob("jupyter_kernel_singular/singular-mode/*"))]
, cmdclass={'install': install}
)