File: ipython.py

package info (click to toggle)
python-vispy 0.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,240 kB
  • sloc: python: 57,407; javascript: 6,810; makefile: 63; sh: 5
file content (58 lines) | stat: -rw-r--r-- 1,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""Entry point for vispy's IPython bindings"""

from distutils.version import LooseVersion


def load_ipython_extension(ipython):
    """ Entry point of the IPython extension

    Parameters
    ----------

    ipython : IPython interpreter
        An instance of the IPython interpreter that is handed
        over to the extension

    """
    import IPython

    # don't continue if IPython version is < 3.0
    ipy_version = LooseVersion(IPython.__version__)
    if ipy_version < LooseVersion("3.0.0"):
        ipython.write_err("Your IPython version is older than "
                          "version 3.0.0, the minimum for Vispy's"
                          "IPython backend. Please upgrade your IPython"
                          "version.")
        return

    _load_webgl_backend(ipython)


def _load_webgl_backend(ipython):
    """ Load the webgl backend for the ipython notebook"""

    from .. import app
    app_instance = app.use_app("ipynb_webgl")

    if app_instance.backend_name == "ipynb_webgl":
        ipython.write("Vispy IPython module has loaded successfully")
    else:
        # TODO: Improve this error message
        ipython.write_err("Unable to load webgl backend of Vispy")


def unload_ipython_extension(ipython):
    """ Unload the ipython extension

    Parameters
    ----------

    ipython : IPython interpreter
        An instance of the IPython interpreter that is handed
        over to the extension

    """
    pass