diff --git a/MANIFEST.in b/MANIFEST.in index 4bd0a6e..9561fb1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1 @@ include README.rst -graft kernelspec diff --git a/kernelspec/kernel.json b/kernelspec/kernel.json deleted file mode 100644 index 9e9dbf2..0000000 --- a/kernelspec/kernel.json +++ /dev/null @@ -1,5 +0,0 @@ -{"argv":["python3","-m","bash_kernel", "-f", "{connection_file}"], - "display_name":"Bash", - "language":"bash", - "codemirror_mode":"shell" -} diff --git a/setup.py b/setup.py index c20ddd8..6e31310 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,29 @@ from distutils.core import setup from distutils.command.install import install +import json +import os.path import sys +kernel_json = {"argv":[sys.executable,"-m","bash_kernel", "-f", "{connection_file}"], + "display_name":"Bash", + "language":"bash", + "codemirror_mode":"shell" +} + class install_with_kernelspec(install): def run(self): + # Regular installation install.run(self) - from IPython.kernel.kernelspec import install_kernel_spec - install_kernel_spec('kernelspec', 'bash', replace=True) + + # 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, 'bash') + ensure_dir_exists(destdir) + with open(os.path.join(destdir, 'kernel.json'), 'w') as f: + json.dump(kernel_json, f, sort_keys=True) + + # TODO: Copy resources once they're specified with open('README.rst') as f: readme = f.read()