mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
install hook improvements
This commit is contained in:
parent
5a26e391d9
commit
b765e641d9
1 changed files with 18 additions and 7 deletions
25
setup.py
25
setup.py
|
@ -56,7 +56,7 @@ def build_tables():
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
|
|
||||||
|
|
||||||
def install_jupyter_hook(root=None):
|
def install_jupyter_hook(prefix=None, root=None):
|
||||||
"""Make xonsh available as a Jupyter kernel."""
|
"""Make xonsh available as a Jupyter kernel."""
|
||||||
if not HAVE_JUPYTER:
|
if not HAVE_JUPYTER:
|
||||||
print('Could not install Jupyter kernel spec, please install '
|
print('Could not install Jupyter kernel spec, please install '
|
||||||
|
@ -76,13 +76,16 @@ def install_jupyter_hook(root=None):
|
||||||
with open(os.path.join(d, 'kernel.json'), 'w') as f:
|
with open(os.path.join(d, 'kernel.json'), 'w') as f:
|
||||||
json.dump(spec, f, sort_keys=True)
|
json.dump(spec, f, sort_keys=True)
|
||||||
if 'CONDA_BUILD' in os.environ:
|
if 'CONDA_BUILD' in os.environ:
|
||||||
root = sys.prefix
|
prefix = sys.prefix
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
root = root.replace(os.sep, os.altsep)
|
prefix = prefix.replace(os.sep, os.altsep)
|
||||||
print('Installing Jupyter kernel spec...')
|
user = ('--user' in sys.argv)
|
||||||
|
print('Installing Jupyter kernel spec:')
|
||||||
|
print(' root: {0!r}'.format(root))
|
||||||
|
print(' prefix: {0!r}'.format(prefix))
|
||||||
|
print(' as user: {0}'.format(user))
|
||||||
KernelSpecManager().install_kernel_spec(
|
KernelSpecManager().install_kernel_spec(
|
||||||
d, 'xonsh', user=('--user' in sys.argv), replace=True,
|
d, 'xonsh', user=user, replace=True, prefix=prefix)
|
||||||
prefix=root)
|
|
||||||
|
|
||||||
|
|
||||||
class xinstall(install):
|
class xinstall(install):
|
||||||
|
@ -90,7 +93,15 @@ class xinstall(install):
|
||||||
def run(self):
|
def run(self):
|
||||||
clean_tables()
|
clean_tables()
|
||||||
build_tables()
|
build_tables()
|
||||||
install_jupyter_hook(self.root if self.root else None)
|
# install Jupyter hook
|
||||||
|
root = self.root if self.root else None
|
||||||
|
prefix = self.prefix if self.prefix else None
|
||||||
|
try:
|
||||||
|
install_jupyter_hook(prefix=prefix, root=root)
|
||||||
|
except Exception:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
print('Installing Jupyter hook failed.')
|
||||||
install.run(self)
|
install.run(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue