[IPython-dev] cairo renderhook

Paul Ivanov pi at berkeley.edu
Tue Jun 3 12:49:17 EDT 2014


Stuart Axon, on 2014-06-03 03:53,  wrote:
> I’ve made a simple render hook for cairo surfaces and contexts

Thanks for sharing, Stuart

> How can I package this so people can use it easily ?

The easiest way would be to make it into an IPython extension,
and list it on this page:
https://github.com/ipython/ipython/wiki/Extensions-Index

The directions for how to make an extension are linked to from
there, but I reproduce them here to convince you (and others)
that it really is simple:

An IPython extension is an importable Python module that has a
couple of special functions to load and unload it. Here is a
template:

  # myextension.py
  
  def load_ipython_extension(ipython):
      # The `ipython` argument is the currently active `InteractiveShell`
      # instance, which can be used in any way. This allows you to register
      # new magics or aliases, for example.
  
  def unload_ipython_extension(ipython):
      # If you want your extension to be unloadable, put that logic here.

This load_ipython_extension() function is called after your
extension is imported, and the currently active InteractiveShell
instance is passed as the only argument. You can do anything you
want with IPython at that point.

load_ipython_extension() will be called again if you load or
reload the extension again. It is up to the extension author to
add code to manage that.

Useful InteractiveShell methods include
register_magic_function(), push() (to add variables to the user
namespace) and drop_by_id() (to remove variables on unloading).

You can put your extension modules anywhere you want, as long as
they can be imported by Python’s standard import mechanism.
However, to make it easy to write extensions, you can also put
your extensions in extensions/ within the IPython directory. This
directory is added to sys.path automatically.

When your extension is ready for general use, please add it to
the extensions index. We also encourage you to upload it to PyPI
and use the Framework :: IPython classifier, so that users can
install it with standard packaging tools.

http://ipython.org/ipython-doc/dev/config/extensions/index.html#writing-extensions

best,
-- 
                   _
                  / \
                A*   \^   -
             ,./   _.`\\ / \
            / ,--.S    \/   \
           /  `"~,_     \    \
     __o           ?
   _ \<,_         /:\
--(_)/-(_)----.../ | \
--------------.......J
Paul Ivanov
ipython and matplotlib core developer
http://pirsquared.org



More information about the IPython-dev mailing list