Skip to content

Commit

Permalink
Install nbextension the Jupyter 5.3+ way
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtabor committed Apr 2, 2018
1 parent 2e563f7 commit 4a26a55
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 39 deletions.
5 changes: 5 additions & 0 deletions nbtools.json
@@ -0,0 +1,5 @@
{
"load_extensions": {
"nbtools/nbtools": true
}
}
4 changes: 2 additions & 2 deletions nbtools/__init__.py
Expand Up @@ -7,8 +7,8 @@
import IPython

__author__ = 'Thorin Tabor'
__copyright__ = 'Copyright 2016-2017, Regents of the University of California & Broad Institute'
__version__ = '0.1.6'
__copyright__ = 'Copyright 2016-2018, Regents of the University of California & Broad Institute'
__version__ = '0.1.7'
__status__ = 'Beta'
__license__ = 'BSD'

Expand Down
54 changes: 17 additions & 37 deletions setup.py
@@ -1,51 +1,30 @@
import os
from distutils.core import setup
from setuptools.command.install import install as _install
from setuptools.command.develop import develop as _develop


def _post_install():
import subprocess
from distutils import log
log.set_verbosity(log.DEBUG)

try:
# Enable the required nbextension for ipywidgets
subprocess.call(["jupyter", "nbextension", "enable", "--py", "widgetsnbextension"])

# Enable the GenePattern Notebook extension
subprocess.call(["jupyter", "nbextension", "install", "--py", "nbtools"])
subprocess.call(["jupyter", "nbextension", "enable", "--py", "nbtools"])
subprocess.call(["jupyter", "serverextension", "enable", "--py", "nbtools"])
except:
log.warn("Unable to automatically enable Notebook Tool Manager extension for Jupyter.\n" +
"Please manually enable the extension by running the following commands:\n" +
"jupyter nbextension enable --py widgetsnbextension\n" +
"jupyter nbextension install --py nbtools\n" +
"jupyter nbextension enable --py nbtools\n" +
"jupyter serverextension enable --py nbtools\n")


class NBInstall(_install):
def run(self):
_install.run(self)
self.execute(_post_install, [], msg="Running post install task")


class NBDevelop(_develop):
def run(self):
_develop.run(self)
self.execute(_post_install, [], msg="Running post develop task")
def get_data_files():
"""
Get the data files for the package.
"""
return [
('share/jupyter/nbextensions/nbtools', [
'nbtools/static/nbtools.js',
'nbtools/static/toolbox.css',
'nbtools/static/toolbox.js',
]),
('etc/jupyter/nbconfig/notebook.d', ['nbtools.json']),
]


setup(name='nbtools',
packages=['nbtools'],
version='0.1.6',
version='0.1.7',
description='A lightweight manager for registering and browsing Jupyter tools',
license='BSD',
author='Thorin Tabor',
author_email='thorin@broadinstitute.org',
url='https://github.com/genepattern/nbtool-manager',
download_url='https://github.com/genepattern/nbtool-manager/archive/0.1.6.tar.gz',
download_url='https://github.com/genepattern/nbtool-manager/archive/0.1.7.tar.gz',
keywords=['genepattern', 'genomics', 'bioinformatics', 'ipython', 'jupyter'],
classifiers=[
'Development Status :: 4 - Beta',
Expand All @@ -61,7 +40,8 @@ def run(self):
'notebook>=4.2.0',
'ipywidgets>=5.0.0',
],
cmdclass={'install': NBInstall, 'develop': NBDevelop},
package_data={'nbtools': ['static/nbtools.js', 'static/toolbox.js', 'static/toolbox.css',
'jsobject/backend_context.js', 'jsobject/jsobject.py', 'jsobject/utils.py', 'jsobject/__init__.py']},
data_files=get_data_files(),
)

0 comments on commit 4a26a55

Please sign in to comment.