3

I have a directory structure as so:

/my_module

init.py

A/

  __init__.py

  a.pyx

B/

  __init__.py

  b.pyx

In b.pyx I want to cimport functions from A.a. A regular python import works, but a cimport always fails.

Also, I'm compiling A/ and B/ separately because I couldn't figure out how to put a setup.py in the top module.

Can anyone help here?

0 _
  • 10,524
  • 11
  • 77
  • 109
user926983
  • 33
  • 1
  • 4
  • 1
    Have you read the part of the documentation on `cimport`? It is *not* like your usual `import`. I'm asking because I made that mistake myself when I tried out Cython. Reading the relevant tutorial sections again, this time actually paying attention, naturally helped a ton ;) –  Sep 03 '11 at 20:37
  • [Here's the relevant documentation](http://docs.cython.org/src/userguide/sharing_declarations.html) – Lewis Ellis Sep 03 '11 at 23:02

1 Answers1

3

You have to create a cython declaration file, a .pxd

It shall contain only declarations of classes and functions that you want to import.

fabrizioM
  • 46,639
  • 15
  • 102
  • 119