1

I was wondering if there is a way to create a single .pyd with cython from a pure python package keeping the package hierarchy.

I mean if the package name is A and inside it there are modules B and C (with their respective folders and init files)

A/
----> __init__py
----> A.py
----> B/
      ----> __init__.py
      ----> B.py
      ----> something.py
----> C/
      ----> __init__.py
      ----> C.py

can I generate a single A.pyd file that allows me to do things like

import A.C
import A.B.something

At this point I know that I can get a single pyd file using .pyx files and the include statement, but this alternative doesnt respect the package hierarchy.

Any help will be very much appreciated

user20679
  • 442
  • 4
  • 17

1 Answers1

0

You can create module objects in code; see this question

You could use your includes, and then create module objects in code. That should allow you to import sub-packages. If you get a working solution, please post that back here. It would be a neat trick.

It would also be interesting to know why you want to use modules as namespaces rather than, say, classes for your namespaces, which would work immediately and could give you a very similar API from calling code.

Community
  • 1
  • 1
Caleb Hattingh
  • 9,005
  • 2
  • 31
  • 44