ExtensionPackageHOWTO

From Inkscape Wiki
Revision as of 12:17, 8 May 2007 by Playful geometer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Packages as Extensions: a HOWTO

This page will teach you how to create and distribute one or more extensions that rely on a package.

Start by creating a root folder to contain your package and extensions i.e. pathjiggleroot

You must make a package out of any modules you have. Add all of the modules into one folder i.e. pathjiggleroot/pathjiggle and create a package from those modules. If you do not know how to create a python package, follow the instrctions here: [1].

Secondly, you must create the necessary .inx descriptor and .py Effect object that use your package. Make sure to use the full path name when importing into your Effect object file i.e. import pathjiggle.smoothjiggle OR from pathjiggle import smoothjiggle OR from pathjiggle.smoothjiggle import *

Use python distutils to create a setup.py script that will install your package onto the users system so that the libraries will always be available to python regardless of your current working directory. There is some good documentation of creating distutils setup scripts here.

An example of a setup.py script here

#!/usr/bin/env python from distutils.core import setup import os import glob dataFiles = [] if os.name == "posix": print "Inkscape extensions will be automatically installed on this Linux-based system" dataFiles.append(("/usr/share/inkscape/extensions/", [i for i in glob.glob(os.path.join("inkex", "*.*"))] )) else: print "You are not running Linux, therefore you must install Inkscape extensions manually by copying files in the inkex directory to the Inkscape extensions directory on your system" setup(name='playsvg', version='0.2', description='playsvg: making graphical programming as easy as py', author='playful_geometr', author_email='justinbarca@gmail.com', url='http://sourceforge.net/projects/play-svg/', packages=['playsvg'], data_files=dataFiles #data_files = [("scripts",[os.path.join("scripts", i) for i in glob.glob(os.path.join("scripts *.py"))] ), ("", ["README.TXT"]), ("inkex",[os.path.join("inkex", i) for i in glob.glob(os.path.join("inkex *.py"))] ) ] )