[Pyrex] using .pxds from inside packages

Kevin Turner acapnotic at twistedmatrix.com
Fri Sep 24 03:29:05 CEST 2004


On Tue, 2004-07-13 at 09:39, Itamar Shtull-Trauring wrote:
> I'm trying to use a .pxd that is inside a package, so I need to add its
> directory to the list of includes for pyrexc. Pyrex Distutils doesn't
> support include_dirs from the Extension at the moment.
> 
> There are two ways to solve this:
[...]
> 2. Distutils improvement so it is possible to pass include dirs. What I
> did was:
> 
> class build_ext(build_ext):
> 
>     def pyrex_compile(self, source):
>         result = Main.compile(source, Main.CompilationOptions(include_path=["package"]))
>         if result.num_errors <> 0:
>             sys.exit(1)

except that when I tried that, I lost all the reasonable defaults for
CompilationOptions.  So my version currently looks like

from Pyrex.Distutils import build_ext as build_ext1
class build_ext(build_ext1):
    def pyrex_compile(self, source):
        from Pyrex.Compiler import Main
        import copy, sys
        opts = copy.copy(Main.default_options)
        opts.include_path=["somepackage"]
        result = Main.compile(source, opts)
        if result.num_errors <> 0:
            sys.exit(1)

On Tue, 2004-07-13 at 18:29, Greg Ewing wrote: 
> There's a not-yet-documented feature which may help.
> You can do
> 
>   cimport package.pyxmodule
> 
> and it will look for a file called "package.pyxmodule.pxd".
> The file doesn't have to be in any particular directory
> as long as it's somewhere on the include path.

That's, um, unexpected.  I expected it to look for
package/pyxmodule.pxd, and don't really understand when
package.pyxmodule.pxd would be useful.

-- 
The moon is waxing gibbous, 73.4% illuminated, 9.7 days old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20040923/009a11af/attachment.bin


More information about the Pyrex mailing list