Ensure conda build will also install the jupyter kernel spec

This commit is contained in:
Morten Enemark Lund 2015-09-30 15:26:44 +02:00 committed by Anthony Scopatz
parent 80b00652ee
commit 7e8b24153a
3 changed files with 22 additions and 7 deletions

View file

@ -1 +1 @@
python setup.py install
python setup.py install --conda

View file

@ -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

View file

@ -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,6 +59,16 @@ def install_jupyter_hook():
"language":"xonsh",
"codemirror_mode":"shell",
}
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)
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:
@ -61,7 +76,6 @@ def install_jupyter_hook():
print('Installing Jupyter kernel spec...')
install_kernel_spec(d, 'xonsh', user=('--user' in sys.argv), replace=True)
class xinstall(install):
def run(self):
clean_tables()