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

Add flag for Makefile dependency rules generation #1214

Closed
robertwb opened this issue Jan 26, 2011 · 9 comments
Closed

Add flag for Makefile dependency rules generation #1214

robertwb opened this issue Jan 26, 2011 · 9 comments

Comments

@robertwb
Copy link
Contributor

Add flag that will make cython output a rule suitable for make describing the dependencies of the main source file.

like this:

$ cython -M foo.pxd

foo.c: bar.pxd

Migrated from http://trac.cython.org/ticket/655

@robertwb
Copy link
Contributor Author

scoder changed component from Code Generation to Build System
commented

@robertwb
Copy link
Contributor Author

scoder changed priority from major to minor
commented

@gerion0
Copy link
Contributor

gerion0 commented Feb 10, 2020

This would be useful for meson, too. For example, the pxd file is not tracked in this test case.

@scoder
Copy link
Contributor

scoder commented May 24, 2021

Since the cython tool does not deal with dependencies (it's a one-shot command), a better place to implement this seems to be the cythonize frontend.

@dcbaker
Copy link

dcbaker commented May 24, 2021

cython still needs to deal with C headers though, correct? and the pxd file as was pointed out above.

@scoder
Copy link
Contributor

scoder commented May 25, 2021

Cython's dependency collection in Cython.Build.Dependencies does not look at transitive header files but only those that are mentioned directly via cdef extern from clauses. It wouldn't be able to decide which of them will be included in a platform/configuration specific way by the C preprocessor anyway.

It transitively collects .pxd, and .pxi files, as well as include files from cdef extern from sections (.h, .c, whatever people use there).

I'm pretty sure it also currently does not look into verbatim C code sections (docstrings of cdef extern from), so if they include anything, it won't be noticed. That's probably ok – if users want to include something here, they can just name it as the input file of that section. And if they include different files in a platform dependent way, then a) Cython can't decide it anyway and b) we are probably dealing with system provided header files which don't normally change.

@dcbaker
Copy link

dcbaker commented May 25, 2021

I guess for cython the header files don't matter as long as they shouldn't trigger cython to re-compiler/transpile (at least from Meson's point of view) as the C/C++ compiler will generate its own depfile that would cover the inclusion of C language headers, so for Meson I guess that just means pxd files?

@scoder
Copy link
Contributor

scoder commented Jan 14, 2022

The feature was only added to the cythonize command for now, in #4563.

Whether it should be added to the cython command as well is less obvious since it does not currently deal with dependencies at all. Only cythonize has this intention.

@scoder scoder modified the milestones: 3.0, 0.29.27 Jan 28, 2022
@scoder
Copy link
Contributor

scoder commented Jan 28, 2022

Backported to 0.29.27 in #4576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants