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
|
from setuptools import setup
from setuptools.command.install import install
import json
import os
import sys
kernel_json = {"argv": [sys.executable, "-m", "scilab_kernel", "-f",
"{connection_file}"],
"display_name": "Scilab",
"language": "scilab",
"codemirror_mode": "Octave"
}
class install_with_kernelspec(install):
def run(self):
# Regular installation
install.run(self)
# Now write the kernelspec
from IPython.kernel.kernelspec import KernelSpecManager
from IPython.utils.path import ensure_dir_exists
destdir = os.path.join(KernelSpecManager().user_kernel_dir, 'scilab')
ensure_dir_exists(destdir)
with open(os.path.join(destdir, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
with open('README.rst') as f:
readme = f.read()
# get the library version from the file
with open('scilab_kernel.py') as f:
lines = f.readlines()
for line in lines:
if line.startswith('__version__'):
version = line.split()[-1][1:-1]
svem_flag = '--single-version-externally-managed'
if svem_flag in sys.argv:
# Die, setuptools, die.
sys.argv.remove(svem_flag)
setup(name='scilab_kernel',
version=version,
description='A Scilab kernel for IPython',
long_description=readme,
author='Steven Silvester',
author_email='steven.silvester@ieee.org',
url='https://github.com/blink1073/scilab_kernel',
py_modules=['scilab_kernel'],
cmdclass={'install': install_with_kernelspec},
install_requires=['scilab2py', 'IPython >= 3.0'],
classifiers=[
'Framework :: IPython',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: System :: Shells',
]
)
|