-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
59 lines (54 loc) · 1.82 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
57
58
59
import sys
import os
import json
import pkgutil
from distutils import log
from distutils.command.install import install
from setuptools import setup
try:
from jupyter_client.kernelspec import install_kernel_spec
except ImportError:
from IPython.kernel.kernelspec import install_kernel_spec
from IPython.utils.tempdir import TemporaryDirectory
kernel_json = {
'argv': [sys.executable,
'-m', 'nix-kernel',
'-f', '{connection_file}'],
'display_name': 'nix',
'language': 'Nix',
'name': 'nix',
}
class install_with_kernelspec(install):
def run(self):
install.run(self)
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)
log.info('Installing kernel spec')
kernel_name = kernel_json['name']
try:
install_kernel_spec(td, kernel_name, user=self.user,
replace=True)
except:
install_kernel_spec(td, kernel_name, user=not self.user,
replace=True)
setup(name='nix-kernel',
version='0.1.0',
description='A nix-repl kernel for Jupyter',
author='Zach Collins',
author_email='[email protected]',
license='MIT',
url="https://github.com/corps/nix-kernel",
cmdclass={'install': install_with_kernelspec},
install_requires=[
'pexpect >= 4.0',
'notebook >= 4.0'],
packages=['nix-kernel'],
classifiers=[
'Framework :: IPython',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: System :: Shells',
]
)