Yurttas/PL/SL/python/docs/core-python-programming/doc/20/dist/node11.html

Revision as of 19:34, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<div class="navigation"> {| width="100%" cellspacing="2" align="center" | yurttas/PL/SL/python/docs/core-python-programming/doc/20/dist/describing-extensions.html|[[Ima...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

3.3.1 Extension names and packages

The first argument to the Extension constructor is always the name of the extension, including any package names. For example,

Extension("foo", ["src/foo1.c", "src/foo2.c"])

describes an extension that lives in the root package, while

Extension("pkg.foo", ["src/foo1.c", "src/foo2.c"])

describes the same extension in the pkg package. The source files and resulting object code are identical in both cases; the only difference is where in the filesystem (and therefore where in Python's namespace hierarchy) the resulting extension lives.

If you have a number of extensions all in the same package (or all under the same base package), use the ext_package keyword argument to setup(). For example,

setup(...
      ext_package = "pkg",
      ext_modules = [Extension("foo", ["foo.c"]),
                     Extension("subpkg.bar", ["bar.c"])]
     )

will compile foo.c to the extension pkg.foo, and bar.c to pkg.subpkg.bar.


See About this document... for information on suggesting changes.