How to Ignore Cython, even if found
See original GitHub issueCurrently, importing setuptools.command.build_ext
pulls in a Cython
dependency if it finds any Cython on a system.
That is not in all cases ideal, e.g. in a package manager (such as spack) or a virtual python environment that does not have a cython installed, while at the same time a system-wide Cython exists. In such a setup, nearly always binary incompatibilities with the system-wide python install will occur.
Is there any way to express “try not to import cython (even when found)” to setuptools?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
How do I disable Cython? - python - Stack Overflow
Use following command to find the package rpm -qa |grep cython. Then if found then copy past your package name in this command...
Read more >How to ignore the annoying Cython warnings in PyPy 6.0
1: if you compile it you still get the warning, even if you locally installed a newer version of Cython. There is not...
Read more >Pure Python Mode — Cython 3.0.0a11 documentation
This is accomplished via an augmenting . pxd file, via Python type PEP-484 type annotations (following PEP 484 and PEP 526), and/or via...
Read more >How to find out where an AttributeError is ignored
the problem? So far, I don't even know in what file the error is ignored. ... was ignored, but Cython does not reveal...
Read more >"Modern" way to build packages with C (Cython) extensions
Regarding setuptools docs specifically, if you find any ... SciPy is working to make cython more compatible with meson , but it is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ax3l: I don’t. I’d suggest starting with the mailing list or maybe file an issue with their tracker to explain the issue and get advice on how to proceed.
Thanks @ax3l for the reproducer. I’ve uploaded it as this gist. I then made a couple of revisions. The first was to specify a base image, which I suspect was necessary because I’m testing on macOS. At that point, I was able to run the build and get the error you described.
But I noticed one thing - that you’re not in fact installing Cython system-wide; you’re installing it in the user site (
pip install --user
). And the way user-local works is it’s shared across different Python installs… which clarifies the answer to the question, how isimport cython
succeeding.In the next revision, I installed Cython system-wide, and the issue goes away. Now that Cython is installed only to the system Python 2.7, it no longer appears in the miniconda install of Python 2.7, and all is well.
In rev 4, I took another tack and disabled that user-local environment before invoking the build. This also bypasses the issue. One could alternatively have set
PYTHONNOUSERSITE=1
.I think this demonstrates that the issue originates from an incorrect usage of user-local environments and presents a couple of plausible workarounds.
I do sympathize with the issue and thinking about the presented workaround in Setuptools, I’m reluctant to go with that approach because of the complexity of behavior it adds on import. If on the other hand cython has or could add a call to check that it’s viable in this environment, like
cython.assert_viable()
, that is something I would be willing to add, something like:In other words, if Cython is willing to support this use-case, then setuptools will support it as well.