question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix for cimport from PEP420 namespace

See original GitHub issue

We have a project (https://github.com/cherab) that is split into a number of different sub-packages. Different teams/labs own the different sub-packages. We use namespaces to pull the separate packages together to appear as a single package. We have recently tried to make the package installable from pypi, however we have encountered an issue with cython compilation:

pip install cherab pip install cherab-openadas

The second package (dependent on the first) fails to compile, saying it can not find the pxd files. On investigating, pip appears to set up a PEP420 namespace where there is no __init__.py in the root package. If I manually add an __init__.py to the root of the package and try pip again, the cython compilation for cherab-openadas succeeds. Given this, I had a look through the cython source and noticed that during the pxd search, only paths with __init__.py/pxd files are scanned. I removed the relevant check in Cython.Utils.search_include_directories() (on 0.29.x branch) and attempted the re-installation with pip in a clean environment. The compilation and installation was successful.

Given PEP420, is there any explicit need for the __init__.* check? Could it be removed? On first look, I can’t see any reason it would cause a problem.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
scodercommented, Apr 11, 2019

Definitely master.

0reactions
KimiNewtcommented, Aug 14, 2022

I’ve encountered this issue as well, and because of our build system it is very difficult (not to mention unnecessary) to add __init__.pys everywhere. Perhaps @mkoeppe 's change can be done under a flag/directive?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 420 – Implicit Namespace Packages
A namespace package will not be constrained by a fixed __path__ , computed from the parent path at namespace package creation time.
Read more >
I don't need `__init__.py`? PEP 420 and namespace ...
today I talk about namespace packages, what PEP 420 is, and why I don't use namespace packagesplaylist: ...
Read more >
Python Namespace Packages - YouTube
python #setuptools #packaging #namespacing #django #papermergeIn this screencast we will learn about namespace packaging and few caveats ...
Read more >
Backport PEP420 namespace package support from Cython 3
After #33011, downstream packages that use Cython and cimport Sage modules need to activate PEP 420 namespace package support in Cython using with ......
Read more >
Current state of python namespace packages - Stack Overflow
setup.py file for my_data.source_a from setuptools import setup, ... This type of namespace package is defined in PEP 420 and is available ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found