From 7e8b24153a019d86240d2eed793fbcd08a4a7489 Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Wed, 30 Sep 2015 15:26:44 +0200 Subject: [PATCH] Ensure conda build will also install the jupyter kernel spec --- recipe/bld.bat | 2 +- recipe/meta.yaml | 3 ++- setup.py | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/recipe/bld.bat b/recipe/bld.bat index aa8a1fc34..36aedba35 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -1 +1 @@ -python setup.py install \ No newline at end of file +python setup.py install --conda \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 1fd5a8a27..41db63f39 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -6,7 +6,7 @@ source: path: ../ build: - script: python setup.py install + script: python setup.py install --conda number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} entry_points: - xonsh = xonsh.main:main @@ -15,6 +15,7 @@ requirements: build: - python - ply + - jupyter run: - python - ply diff --git a/setup.py b/setup.py index ddf40ab21..5f35f3a01 100755 --- a/setup.py +++ b/setup.py @@ -28,6 +28,11 @@ 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(): for f in TABLES: if os.path.isfile(f): @@ -54,13 +59,22 @@ def install_jupyter_hook(): "language":"xonsh", "codemirror_mode":"shell", } - with TemporaryDirectory() as d: - os.chmod(d, 0o755) # Starts off as 700, not user readable + if CONDA: + d = os.path.join(os.environ['PREFIX'] + + '/share/jupyter/kernels/xonsh/') + os.makedirs(d, exist_ok=True) + 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) - print('Installing Jupyter kernel spec...') - install_kernel_spec(d, 'xonsh', user=('--user' in sys.argv), replace=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...') + install_kernel_spec(d, 'xonsh', user=('--user' in sys.argv), replace=True) class xinstall(install): def run(self):