Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython does not include implicit namespace packages (PEP 420) #3301

samufi opened this issue Jan 2, 2020 · 1 comment

Cython does not include implicit namespace packages (PEP 420) #3301

samufi opened this issue Jan 2, 2020 · 1 comment


Copy link

@samufi samufi commented Jan 2, 2020


When cimporting extensions from external packages, cython considers only folders that contain an __init__.* file. Hence, cython does not search implicit namespace packages, i.e. superfolders of packages, as described in PEP 420.

Tested cython version

Cython 0.29.15 with Python 3.7 on Windows 10 x64.

Steps to reproduce

Create a namespace package with the following structure:

├── nsp
│   └── A
|       ├── extension.pxd
|       ├── extension.pyx
│       └──

whereby nsp is the namespace package and A is the actual package. Try cimport nsp.A.extension in any other cython file after installing nsp.A. You will obtain an error indicating that extension.pxd has not been found (see also here).


Create an empty file __init__.pxd in the folder nsp. This file should be ignored by regular python, as it is not a *.py file, but allows cython to classify the folder nsp as package.

Steps to fix

Change the mechanism that determines whether a file name describes a package. For example, change the method is_package_dir in to recursively check subdirectories.


This comment has been minimized.

Copy link

@CnlPepper CnlPepper commented Jan 6, 2020

Hello, I fixed this for Cython 3. See #2918. It would be useful if it were back ported to 0.29.x, but unfortunately I have no time at present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.