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

Install mathjax for offline use #714

Merged
merged 2 commits into from Aug 22, 2011
Merged

Conversation

minrk
Copy link
Member

@minrk minrk commented Aug 21, 2011

Add simple function to IPython.external for installing mathjax to the static dir for offline use. It checks for permission, existence, etc. and allows for installing from different tags, e.g. if you want to use stable (v1.1) or master.

All you need to do to get offline mathjax is:

from IPython.external.mathjax import install_mathjax
install_mathjax()

This could be located somewhere else, or also called from a magic, but external seemed the most logical place, since it is for bundling an external library.

I also reversed the priority of offline/cdn mathjax, so offline mathjax is preferred, since it is presumably less expensive to load. Of course, this is only true in the local network case, and a notebook server that's run from a real server would probably prefer to use the cdn. This is in a separate commit, so it's easy to rollback if we want to keep the CDN priority.

from IPython.external.mathjax import install_mathjax

install_mathjax()

* add mathjax destination to gitignore
@fperez
Copy link
Member

fperez commented Aug 21, 2011

I actually was asking @ellisonbg about the same of switching priorities. On Friday for some odd reason the mathjax CDN was timing out on my firefox session (it seems to be some dd interaction with firebug, couldn't quite figure it out) and I had to do this switch locally just so I could keep working. But I'd like Brian to give us his take on it.

In terms of the other code, a couple of comments.

  • Let's keep IPython.external to be for the actual external library hosting, so that we know that IPython.external in principle can be empty if all dependencies are provided, for example, by a linux distro.
  • would it be possible/sensible to offer the option to do a user-level install (like the --local option)? So that people could install it without sudo access?

I'm not sure how much the latter is really needed, since you tend to only not have sudo on servers, which by definition need good net connectivity. This is mostly needed for laptops likely to be offline. I just want to float the thought before we finalize it and merge.

@minrk
Copy link
Member Author

minrk commented Aug 21, 2011

  • Let's keep IPython.external to be for the actual external library hosting, so that we know that IPython.external in principle can be empty if all dependencies are provided, for example, by a linux distro.

I think this makes perfect sense...but then where should we move the Qt import code to, since it doesn't qualify? And where should the mathjax install go? IPython.utils? IPython.frontend.html.notebook.util?

The ssh code was also put into external, with the argument that it is really a standalone tool, that could be brought into another package (specifically pyzmq). It can be moved to IPython.utils as well

  • would it be possible/sensible to offer the option to do a user-level install (like the --local option)? So that people could install it without sudo access?

It would be possible, as I think was discussed on IRC or Skype, to add some location in IPYTHON_DIR, but it would mean adding three-level logic for loading MathJax: 1. user-installed, 2. IPython-lib installed, 3. CDN.

@fperez
Copy link
Member

fperez commented Aug 22, 2011

It seems to me that IPython.utils is fine... I didn't realize that we had let other things slip into external. We should probably clean that up later on, though by now we'll have to be more careful and put in deprecation warnings, as someone is likely to have started using those locations.

As for the local install, we can leave that for a future pass, if you prefer. I don't have strong feelings about it.

@ellisonbg
Copy link
Member

I think external is a much better place than this. MathJax is a an external dependency that we would ship if it were not smaller. If we don't do external, then I think it should be in IPython.frontend.html.notebook.

@minrk
Copy link
Member Author

minrk commented Aug 22, 2011

IPython.frontend.html.notebook.util is where I put it the first time, but I moved it to external, based on the idea that no users should ever actually import a 5-level-down module.

If we want IPython.external to be something that distributors can easily ship without, then we should change all our conditional external imports, such that the try/except is in the actual import, rather then relying on IPython.external to do the logic:

try:
    import package
except ImportError:
    from IPython.external import package

We frequently do just the external import, and let the IPython.external package perform the try/exceptfor whether to use the bundled version or not.

@ellisonbg ellisonbg merged commit 89aca0b into ipython:htmlnotebook Aug 22, 2011
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.

None yet

3 participants