Update setup.py with too use default jupyter kernel install mechanism on conda

This commit is contained in:
Morten Enemark Lund 2016-04-25 11:59:48 +02:00
parent 6a61bfcc4f
commit 16e14058a8

View file

@ -36,11 +36,6 @@ from xonsh import __version__ as XONSH_VERSION
TABLES = ['xonsh/lexer_table.py', 'xonsh/parser_table.py']
CONDA = ("--conda" in sys.argv)
if CONDA:
sys.argv.remove("--conda")
def clean_tables():
"""Remove the lexer/parser modules that are dynamically created."""
for f in TABLES:
@ -71,23 +66,21 @@ def install_jupyter_hook(root=None):
"language": "xonsh",
"codemirror_mode": "shell",
}
if CONDA:
d = os.path.join(sys.prefix + '/share/jupyter/kernels/xonsh/')
os.makedirs(d, exist_ok=True)
with TemporaryDirectory() as d:
os.chmod(d, 0o755) # Starts off as 700, not user readable
if sys.platform == 'win32':
# Ensure that conda-build detects the hard coded prefix
spec['argv'][0] = spec['argv'][0].replace(os.sep, os.altsep)
with open(os.path.join(d, 'kernel.json'), 'w') as f:
json.dump(spec, f, sort_keys=True)
else:
with TemporaryDirectory() as d:
os.chmod(d, 0o755) # Starts off as 700, not user readable
with open(os.path.join(d, 'kernel.json'), 'w') as f:
json.dump(spec, f, sort_keys=True)
print('Installing Jupyter kernel spec...')
KernelSpecManager().install_kernel_spec(
d, 'xonsh', user=('--user' in sys.argv), replace=True,
prefix=root)
if 'CONDA_BUILD' in os.environ:
root = self.prefix
if sys.platform == 'win32':
root = root.replace(os.sep, os.altsep)
print('Installing Jupyter kernel spec...')
KernelSpecManager().install_kernel_spec(
d, 'xonsh', user=('--user' in sys.argv), replace=True,
prefix=root)
class xinstall(install):