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

turn repo into a fully pip-installable package #671

Merged
merged 14 commits into from
Jul 26, 2016

Conversation

jcb91
Copy link
Member

@jcb91 jcb91 commented Jul 18, 2016

Turn setup.py into a proper setuptools installer

  • fix setup.py & MANIFEST.in to ensure all files are included as part of the package
  • replace old installation mechanism with a jupyter contrib subcommand to install/uninstall all of the nbextensions using jupyter's machinery (or the compatibility shims from jupyter_contrib_core for notebook versions < 4.2)
  • fix version to be pep440-compliant
  • add setup.cfg to support universal wheel builds, flake8 linting and isort import sorting
  • add add bumpversion config for easier version management
  • add a module and associated app to migrate old (pre-this PR) installs

 * make a proper package, which can therefore be installed
 * include package data
 * don't modify config as part of pip install, only do it as part of explicit script
 * add setup.cfg to support universal wheel builds
@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

still to do:

  • fix repo name in setup.py
  • edit readme to reflect new installation procedure

@juhasch
Copy link
Member

juhasch commented Jul 18, 2016

So what is the best way to move this to jupyter-contrib ?
Merge and then move ?

Also todo (probably not in this PR, but needs to be done):

  • document templates better
  • document pre-/postprocessors better (and rename some of them for consistency)
  • toc exporter using entrypoints for nbconvert ?

I could work on the first two bullet points. Also, we could autogenerate documentation from the md file. I believe you gave it a try before ?

@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

we could autogenerate documentation from the md file

Not exactly sure what you mean by this - the md files generally are the documentation, as far as I can see?

@juhasch
Copy link
Member

juhasch commented Jul 18, 2016

What I meant was to autogenerate a documentation like standard modules have, i.e. like HTML or PDF docs, usually generated by sphinx or so.

@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

oh, right! I guess this is what gets hosted at, e.g. http://jupyter-notebook.readthedocs.io? But yes, I'm sure we could autogenerate some of the docs/ tree from the existing markdown through nbconvert or similar

@juhasch
Copy link
Member

juhasch commented Jul 18, 2016

I tried to get sphinx to autogenerate documentation from md files some time ago, but got stuck in path problems, i.e. getting sphinx to read from the nbextension directories and getting the graphics imported correctly. It should be doable, however.

Now first things first, let's get this PR ready and the we will see, I guess.

@juhasch
Copy link
Member

juhasch commented Jul 18, 2016

Btw. what is scripts/jupyter-contrib-nbextension for ?

@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

Btw. what is scripts/jupyter-contrib-nbextension for ?

Ah, that's part of the new installation/configuration mechanism, for which I haven't yet written docs/readme. It makes the application callable as a jupyter contrib subcommand. Essentially the installation is now:

pip install jupyter_contrib_nbextensions  # install the pip-package
jupyter contrib nbextension install --user  # install all nbextensions from pip package to jupyter dirs

where the second part is basically just a wrapper around notebook's jupyter nbextension install, (plus shims from jupyter_contrib_core to provide the notebook 4.2-compatible nbextension api).

@juhasch
Copy link
Member

juhasch commented Jul 18, 2016

OK, thanks for the explanation. Sounds good.
Hmm, after installation when trying the jupyter contrib command, I get this:

d:\source.local\IPython-notebook-extensions>jupyter contrib
Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\jupyter-contrib-script.py", line 9, in <module>
    load_entry_point('jupyter-contrib-core==0.3.0', 'console_scripts', 'jupyter-contrib')()
  File "C:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 594, in launch_instance
    app = cls.instance(**kwargs)
  File "C:\Anaconda3\lib\site-packages\traitlets\config\configurable.py", line 405, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 27, in __init__
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 43, in _refresh_subcommands
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2229, in load
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2235, in resolve
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\application.py", line 14, in <module>
    from jupyter_contrib_nbextensions.install import install, uninstall
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\install.py", line 17, in <module>
    import jupyter_contrib_nbextensions.nbconvert_support
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\__init__.py", line 11, in <module>
    from .toc2 import TocExporter
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\toc2.py", line 16, in <module>
    from jupyter_contrib_nbextensions.nbconvert_support import templates_directory
ImportError: cannot import name 'templates_directory'

@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

oh boo, this is something I broke in a rebase, I think. I haven't checked all my CI tests, so it's not surprising I missed something, I guess. I'll check it out now

@jcb91
Copy link
Member Author

jcb91 commented Jul 18, 2016

Yep, seems I accidentally introduced a circular import. I'll rebase to fix this...

@juhasch
Copy link
Member

juhasch commented Jul 19, 2016

This is what I see when trying jupyter contrib command after installing using python setup.py install :

  • Unknown option
C:\Anaconda3\envs\test\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'platform'
  warnings.warn(msg)
  • requests package is missing as dependency
(test) d:\source.local\IPython-notebook-extensions>jupyter contrib
Traceback (most recent call last):
  File "C:\Anaconda3\envs\test\Scripts\jupyter-contrib-script.py", line 9, in <module>
    load_entry_point('jupyter-contrib-core==0.3.0', 'console_scripts', 'jupyter-contrib')()
  File "C:\Anaconda3\envs\test\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Anaconda3\envs\test\lib\site-packages\traitlets\config\application.py", line 594, in launch_instance
    app = cls.instance(**kwargs)
  File "C:\Anaconda3\envs\test\lib\site-packages\traitlets\config\configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 27, in __init__
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 43, in _refresh_subcommands
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2229, in load
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2235, in resolve
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\application.py", line 14, in <module>
    from jupyter_contrib_nbextensions.install import install, uninstall
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\install.py", line 17, in <module>
    import jupyter_contrib_nbextensions.nbconvert_support
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\__init__.py", line 10, in <module>
    from .pre_svg2pdf import SVG2PDFPreprocessor
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\pre_svg2pdf.py", line 15, in <module>
    import requests
ImportError: No module named 'requests'
  • templates_directory is not found
(test) d:\source.local\IPython-notebook-extensions>jupyter contrib
Traceback (most recent call last):
  File "C:\Anaconda3\envs\test\Scripts\jupyter-contrib-script.py", line 9, in <module>
    load_entry_point('jupyter-contrib-core==0.3.0', 'console_scripts', 'jupyter-contrib')()
  File "C:\Anaconda3\envs\test\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Anaconda3\envs\test\lib\site-packages\traitlets\config\application.py", line 594, in launch_instance
    app = cls.instance(**kwargs)
  File "C:\Anaconda3\envs\test\lib\site-packages\traitlets\config\configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 27, in __init__
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_core-0.3.0-py3.5.egg\jupyter_contrib_core\application.p
y", line 43, in _refresh_subcommands
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2229, in load
  File "c:\anaconda3\envs\test\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2235, in resolve
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\application.py", line 14, in <module>
    from jupyter_contrib_nbextensions.install import install, uninstall
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\install.py", line 17, in <module>
    import jupyter_contrib_nbextensions.nbconvert_support
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\__init__.py", line 11, in <module>
    from .toc2 import TocExporter
  File "C:\Users\hasch\AppData\Roaming\Python\Python35\site-packages\jupyter_contrib_nbextensions-0.0.0-py3.5.egg\jupyter_contrib_nbextensio
ns\nbconvert_support\toc2.py", line 16, in <module>
    from jupyter_contrib_nbextensions.nbconvert_support import templates_directory
ImportError: cannot import name 'templates_directory'

@jcb91
Copy link
Member Author

jcb91 commented Jul 22, 2016

@juhasch sorry for silence on this, it's presumably a bunch of bugs I've fixed between the pippify branch (this PR) and my CI branch, which actually includes travis & appveyor testing, since the CI branch seems to work ok. I'll try to investigate soon.

@jcb91
Copy link
Member Author

jcb91 commented Jul 22, 2016

UserWarning: Unknown distribution option: 'platform' warnings.warn(msg)

This a warning resulting from setuptools/distutils differences that I don't understand properly from googling it (everything I can find seems to say that it means you should have setuptools, but I already do, so I don't see how that can be the problem). At any rate, it doesn't actually cause any problems.

requests is missing as a dependency

True, I've apparently fixed this in my CI branch through remaking the test_preprocessors, coincidentally not using requests.

templates_directory is not found

this is just a side-effect of the ImportError in pre_svg2pdf, which means that the function never gets defined...

@juhasch
Copy link
Member

juhasch commented Jul 22, 2016

No worries :-)

So will you update this branch or is it better to try your CI branch ?

@jcb91
Copy link
Member Author

jcb91 commented Jul 22, 2016

will you update this branch or is it better to try your CI branch ?

mm, I don't mind really, but I guess merging my CI commits into my pippify branch might be the simplest. I have a couple of changes to the CI one to make first though, to check that migrating from the old repo works ok...

jcb91 added 10 commits July 23, 2016 23:45
* add function to find templates directory from nbconvert_support package
* update config_scripts to use new package structure
* update some readme files which refer to templates directory
based on a jupyter application calling notebook 4.2-style extension API methods
Also make check for running server more robust
* tests on travis and appveyor via tox
* codecov.yml for github status suppression
* consolidate common operations into functions
* test imports in test_preprocessors
* skip rather than fail on tests which require pandoc if we can't find it
* move svg2pdf inkscape-finding into a function which doesn't raise exceptions, allowing us to skip test if inkscape can't be found, and skip accordingly
* use urllib instead of requests in svg2pdf preprocessor
* fix flake8 complaints
jcb91 added 2 commits July 25, 2016 10:59
 * fix repo URLs in setup.py
 * clarify separation of `jupyter_nbextensions_configurator` in readme
 * add reference to github view for viewing repository readmes
 * update readme with migration instructions
 * formatting update for notbook extension structure in readme
 * fix urls for appveyor
 * move notes about custom installs after regualr instrucitons
 * number installation steps
@jcb91
Copy link
Member Author

jcb91 commented Jul 25, 2016

ok, this seems to have all of its CI tests passing now. I've had a go at updating the readme too.

More information can also be found in the
[Wiki](https://github.com/ipython-contrib/IPython-notebook-extensions/wiki).


The install process has two steps:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should first explain the installation approach, and then describe the steps in detail. How about this:

To install notebook extensions, three steps are required. First, this Python package needs to be installed. Then, the notebook extensions themselves can be copied to the Jupyter data directory.
Finally, the installed notebook extensions can be enabled, either by using built-in Jupyter commands, or more convenient by using the jupyter_nbextensions_configurator server extension.

The Python package installation step is necessary to allow painless installation of the extensions togther with additional items like nbconvert templates, pre-/postprocessors, and exporters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds reasonable. So that would then replace the current bullet points, I guess? PR away 😉

@juhasch
Copy link
Member

juhasch commented Jul 25, 2016

Looks good. I think we should merge and rename the repo.
It is definitely a big improvement compared to master. Great work!

@jfbercher
Copy link
Member

This is really nice indeed! A big and great work!
I will have a closer look tomorrow.

I have some improvements to latex_envs and two related exporters that are almost ready. Perhaps should I wait for the new repo to PR and add entry points to the setup.py? (or PR to @jcb91 pippify?)

@jcb91
Copy link
Member Author

jcb91 commented Jul 25, 2016

Also, I was wondering whether it might be simpler to make the migrate happen automatically on running the install command if pip is importable and lists the old package name (Python-contrib-nbextensions) as installed?

@jcb91
Copy link
Member Author

jcb91 commented Jul 25, 2016

should I wait for the new repo to PR and add entry points to the setup.py?

Not sure what you mean by entrypoints here @jfbercher, what exactly are you attempting to do? point me to a branch if you like 😄

or PR to @jcb91 pippify?

I feel like that might get rather confusing for later merges... I guess you could open a PR against the main master, then you can always rebase your branch later to fix merges locally once this is merged, then force-push the rebased branch to update the PR automatically. I know rebases and forced updates are frowned upon from a git standpoint, but I feel like as long as you've warned people that the branch may be volatile, it's not a problem...

@jfbercher
Copy link
Member

I meant adding entry points in order to register the exporters with the package, thus enabling to call them with a custom short name. This is explained eg here.

There is no urgency, I'll wait for the new repo.

@juhasch
Copy link
Member

juhasch commented Jul 26, 2016

So let's merge.

@juhasch juhasch merged commit 630caaa into ipython-contrib:restructure Jul 26, 2016
@jcb91 jcb91 deleted the pippify branch July 29, 2016 23:35
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

Successfully merging this pull request may close these issues.

3 participants