Author: | Dave Kuhlman |
---|---|
Address: | dkuhlman (at) reifywork (dot) com http://www.reifywork.com |
revision: | 2.14a |
---|
date: | October 25, 2024 |
---|
This document explains how to use the generateDS.py library template to create a package enabling you to distribute a module generated with generateDS.py. This package and the instructions below will help you to create the following:
The latest copy of these instructions is here:
http://www.reifywork.com/librarytemplate_howto.html
and the template package itself is here:
http://www.reifywork.com/librarytemplate-1.0a.zip
These instructions assume the name "peach" as the name of the schema. You should replace "peach" in these instructions with the name of your schema.
Find out more about generateDS.py here: http://www.reifywork.com/generateDS.html
You will need to install Sphinx in order to build the documentation in your package. Learn about Sphinx here: http://sphinx.pocoo.org/.
In the instructions that follow, I'll assume that the name of your XML schema is "peach" and that the name of the module that you generate using generateDS.py will be "peachlib".
Follow these steps:
Unroll the library template (librarytemplate-x.y.zip), for example:
$ unzip librarytemplate-1.0a.zip
Rename the top-level directory created by the previous step, for example:
$ mv librarytemplate-x.y peachlib-1.0a
Or, on MS Windows:
$ rename librarytemplate-x.y peachlib-1.0a
Go to the new directory. For example:
$ cd peachlib-1.0a
Copy your generated modules into this directory. Suggested name is {schema_name}lib.py. For example peachlib.py.
Run quick_start.py (which is in the top level directory). quick_start.py makes changes in the boiler plate provided by librarytemplate; it changes occurrences of "{{schema_name}}" to the name of your schema, which is entered on the command line. For example:
$ python quick_start.py --help $ python quick_start.py --schema-name=peach
Add some more content to the documentation. It is likely that you will want to make additions and changes in the following files:
Generate the documentation. This step requires Sphinx.
First, add the top-level directory of your distribution to your PYTHONPATH environment variable. Sphinx needs to be able to import your library module (peachlib.py). Then, go to the ./docs/ directory and build the HTML documentation:
$ cd docs $ make clean $ make html
You also can build other forms of documentation, e.g. LaTeX and PDF. See the Sphinx documentation, or type:
$ make help
By default, the generated documentation for the module includes lists of the member functions for each class. You can change this by removing the :members: and :undoc-members: options from the file docs/module_contents.txt, and then run:
$ make clean $ make html
again.
Add some functionality and sample code. In particular:
It might be a good idea to include the XML schema from which you generated your library module. You can copy the schema(s) to the schemas/ directory, and/or add a link in file schemas/README.txt that points to a location where it can be found.
Create a distribution file. For example, use either:
$ tar czf peachlib-1.0a.tar.gz peachlib-1.0a
or:
$ zip -r peachlib-1.0a.zip peachlib-1.0a
In order to avoid including backup files and compiled Python modules, you might want to use something like the following:
$ zip -r peachlib-1.0a.zip peachlib-1.0a -x \*~ -x \*.pyc
See the man page on zip for more on the -x command line option. The backslash avoids the shell filename substitution. Adjust this command for your needs. For example, you may need to use "*.bak" instead of "*~".