Skip to content

Allows Jupyter Notebook extension writers to make their extension pip installable!

License

Notifications You must be signed in to change notification settings

jdfreder/jupyter-pip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jupyter-pip

Allows Jupyter notebook extension writers to make their extension pip installable!

Specifically, if you have a module that you've written which is intended for use in the Jupyter notebook and also has Javascript associated with it, this is designed to solve the distribution problem.

Copy&paste

In setup.py

try:
    from jupyterpip import cmdclass
except:
    import pip, importlib
    pip.main(['install', 'jupyter-pip']); cmdclass = importlib.import_module('jupyterpip').cmdclass

and inside the setup(...) call

    install_requires=["jupyter-pip"],
    cmdclass=cmdclass('myplugin', 'myplugin/init'),

Details

You don't need to download this to use it! Instead you just need to modify your package's setup.py to download it at install time.

The following example assumes a folder structure like this:

./myplugin/__init__.py
./myplugin/init.js
./setup.py

Starting with a setup.py file that looks like this:

# -*- coding: utf-8 -*-
from setuptools import setup

setup(
    name='myplugin',
    packages=['myplugin'],
    # ... more setup.py stuff here ...
)

All you need to do is add a try import block and two entries to the setup call to make the project nbextension compatabile:

# -*- coding: utf-8 -*-
from setuptools import setup

try:
    from jupyterpip import cmdclass
except:
    import pip, importlib
    pip.main(['install', 'jupyter-pip']); cmdclass = importlib.import_module('jupyterpip').cmdclass

setup(
    name='myplugin',
    packages=['myplugin'],
    # ... more setup.py stuff here ...
    install_requires=["jupyter-pip"],
    cmdclass=cmdclass('myplugin', 'myplugin/init'),
)

The second argument to the cmdclass call is optional. If specified, the JS module will be loaded alongside the notebook automatically. Note that for widget packages, typically this isn't this best idea. Instead the line would read cmdclass=cmdclass('myplugin') and the widget framework would load the JS when the widget is constructed.

License

New BSD (see ./LICENSE file).

About

Allows Jupyter Notebook extension writers to make their extension pip installable!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages