-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
compilers: add .pxd as a cython header extensions #10146
base: master
Are you sure you want to change the base?
Conversation
What bug does this fix? |
Not that it is wrong, but I would like to understand the reason for this change, because I'm working on a huge refactor branch that affects a lot transpilers so I would like to make sure my branch gets this correct too. |
I pulled this out of my branch for structured_sources with cython, but basically if you try to pass a .pxd file as an order dep (since we don't have depfile support yet), then we'll error with "no compiler can handle .pxd files" |
It's used for generated sources for passing as order-only dependencies ( |
Codecov Report
@@ Coverage Diff @@
## master #10146 +/- ##
==========================================
- Coverage 69.10% 61.49% -7.62%
==========================================
Files 203 203
Lines 43417 43066 -351
Branches 9660 9457 -203
==========================================
- Hits 30005 26485 -3520
- Misses 11121 14466 +3345
+ Partials 2291 2115 -176 Continue to review full report at Codecov.
|
I haven't tested this branch, but I think it's a little bit more complicated than this, we don't pass header_deps to generate_cython_transpile() at all in ninjabackend. I have a branch that fix this already. |
The header dependency issue should be fixed by #10149. |
Right, I'm aware that it's more complicated, but you currently can't even do: py.extension_module('foo', 'foo.pyx', 'foo.pxd') (where 'foo.pxd' is just a static file, but you want to track it as a header) and this will at least fix that part. But you're right, the whole transpile mess is a mess right now. |
Thanks @dcbaker, this looks clearly correct. Cython actually has a third file type, But long story short: I think you should add
Interesting (and complex!). Please let me know if/when you want me to test your branch with the SciPy build @xclaesse. |
Oh ok, I thought it was accepted but didn't produce the correct dependency. LGTM then! |
I’ve added pxi as well, but I’m on my phone so we’ll need to do a squash merge. |
09b2f30
to
1b0d088
Compare
Squashed locally and re-pushed |
Testing this, the configure stage ends with:
The log file has nothing more informative than that one error. Comes from: I'm not sure if that's an actual issue with this PR, or if it simply disagrees with the workaround that we had to use until now. |
On the general topic of this PR: So, this enables .pxd as a "header dep", also known in the ninja manual as an "order-only" dep.
Updates to foo.c force a rebuild of foo.o header.h does NOT force a rebuild of foo.o, and it is not used as input either. What does it do? It must exist, with any timestamp whatsoever. Additionally, if there is a separate build rule for header.h and header.h is considered out of date, it will be built first, before foo.o is built. How does this translate to cython?
In the first case:
In the second case:
It was observed above that this does not actually handle generated pxd files to add them as order-only ("header") deps, so that would mean this PR only unlocks the first case and not the second case. The first case does NOT need header deps to do a clean ("scratch") build. The second case DOES need header deps to do a clean ("scratch") build. Both cases need depfiles, which is an unrelated topic, in order to do an incremental rebuild. |
Given my analysis, I think this is not an urgent 0.62.0 bugfix. Given @rgommers' test above, I'm afraid to merge this without looking a lot closer into the relevant issues, and with the safety net of a development cycle to avoid stable regressions. |
Given that Cython supports depfiles for versions >=0.29.27, I sort of wonder how to add their support to meson and whether this changes anything for this PR |
To connect the dots: this fixes gh-9049.
I think it'll be helpful to derive a new test case from the |
I did add depfile support to cython's non-setuptools frontend, and it's backported into the 0.29.x series -- it just still hasn't been tagged in a new cython release. |
@rgommers, I think this is correct, pxd files are used by cython, but in much the same way that a .h file is used by C/C++?