Git Product home page Git Product logo

jupyter-pip's Introduction

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).

jupyter-pip's People

Contributors

chfw avatar costerwi avatar jchuahtacc avatar jdfreder avatar nicktimko avatar rgbkrk avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.