API Generation CLI

Top-level automatic API generators for Bright.

author:Anthony Scopatz <scopatz@gmail.com>

API Generation

This module is where all of the Bright-specific API generation routines reside. Until now the type system, automatic description, and cython code generation have all be independent of what classes they are wrapping. The functions and classes here are specifically set up to be executed on the Bright code base. Thus, attempting to wrap other codes with the tools developed here would only need to fork this module.

The main module is normally run from the base bright directory as follows:

~ $ cd bright
~/bright $ python bright/apigen/main.py

The function here has the following command line interface:

usage: Generates Bright API [-h] [--debug] [--no-cython] [--no-cyclus]
                            [--dump-desc] [-v]

optional arguments:
  -h, --help     show this help message and exit
  --debug        build with debugging flags
  --no-cython    don't make cython bindings
  --no-cyclus    don't make cyclus bindings
  --dump-desc    print description cache
  -v, --verbose  print more output

Main API

class bright.apigen.main.DescriptionCache(cachefile='build/desc.cache')

A quick persistent cache for descriptions from files. The keys are (classname, filename) tuples. The values are (hashes-of-the-file, description-dictionary) tuples.

Parameters :

cachefile : str, optional

Path to description cachefile.

dump()

Writes the cache out to the filesystem.

isvalid(classname, filename)

Boolean on whether the cach value for a (classname, filename) tuple matches the state of the file on the system.

bright.apigen.main.describe_class(classname, filename, verbose=False)

Returns a description dictionary for a class (called classname) living in a file (called filename).

Parameters :

classname : str

Class to describe.

filename : str

File where the class is implemented. Will remove leading 'bright_' from filename for the puprose of generating other files.

verbose : bool, optional

Flag for printing extra information during description process.

Returns :

desc : dict

Description dictionary of the class.

bright.apigen.main.dumpdesc(ns)

Prints the current contents of the description cache using ns.

bright.apigen.main.genbindings(ns)

Generates bidnings using the command line setting specified in ns.

bright.apigen.main.main()

Entry point for Bright API generation.

bright.apigen.main.newoverwrite(s, filename)

Useful for not forcing re-compiles and thus playing nicely with the build system. This is acomplished by not writing the file if the existsing contents are exactly the same as what would be written out.

Parameters :

s : str

string contents of file to possible

filename : str

Path to file.

Previous topic

Cython Generation

Next topic

Utilities

This Page