Write kernelspec using sys.executable on install

main
Thomas Kluyver 11 years ago
parent 11db1d7d81
commit bdc1e9510f

@ -1,2 +1 @@
include README.rst include README.rst
graft kernelspec

@ -1,5 +0,0 @@
{"argv":["python3","-m","bash_kernel", "-f", "{connection_file}"],
"display_name":"Bash",
"language":"bash",
"codemirror_mode":"shell"
}

@ -1,12 +1,29 @@
from distutils.core import setup from distutils.core import setup
from distutils.command.install import install from distutils.command.install import install
import json
import os.path
import sys 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): class install_with_kernelspec(install):
def run(self): def run(self):
# Regular installation
install.run(self) 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: with open('README.rst') as f:
readme = f.read() readme = f.read()

Loading…
Cancel
Save