Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the python package should install and enable the frontend package when installed #1

Open
bjuergens opened this issue Mar 27, 2018 · 1 comment

Comments

@bjuergens
Copy link
Collaborator

With this it would be trivial to include this plugin in a conda environment.

What needs to be done during package installation:

  • install server extension
  • enable server extension
  • install frontend extension
  • enable frontend extension

Currently we do this by hand and via bash. It needs to be done python and automatically.

according to this blog post it is possible.

Their example the setup.py is this:

import os
from setuptools import setup
from setuptools.command.install import install

from notebook.nbextensions import install_nbextension
from notebook.services.config import ConfigManager
from jupyter_core.paths import jupyter_config_dir

EXT_DIR = os.path.join(os.path.dirname(__file__), 'myext')

class InstallCommand(install):
    def run(self):
        # Install Python package
        install.run(self)

        # Install JavaScript extensions to ~/.local/jupyter/
        install_nbextension(EXT_DIR, overwrite=True, user=True)

        # Activate the JS extensions on the notebook, tree, and edit screens
        js_cm = ConfigManager()
        js_cm.update('notebook', {"load_extensions": {'myext_js/notebook': True}})
        js_cm.update('tree', {"load_extensions": {'myext_js/dashboard': True}})
        js_cm.update('edit', {"load_extensions": {'myext_js/editor': True}})

        # Activate the Python server extension
        server_cm = ConfigManager(config_dir=jupyter_config_dir())
        cfg = server_cm.get('jupyter_notebook_config')
        server_extensions = (cfg.setdefault('NotebookApp', {})
            .setdefault('server_extensions', [])
        )
        if extension not in server_extensions:
            cfg['NotebookApp']['server_extensions'] += ['myext.my_handler']
            server_cm.update('jupyter_notebook_config', cfg)

setup(
    name='myext',
    version='0.1',
    packages=['myext'],
    cmdclass={
        'install': InstallCommand
    }
)
@bjuergens
Copy link
Collaborator Author

better way here: jupyter/notebook#3116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant