-
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
1st class Cython language support #8706
1st class Cython language support #8706
Conversation
This pull request introduces 1 alert when merging 33e06a7 into a493c95 - view on LGTM.com new alerts:
|
For C++ I'm think using a cpp_files = static_library(
'static_library
['foo.pyx'],
override_options : ['cython_language=cpp'],
)
python.extension_module(..., link_with : static_lib) |
This pull request introduces 1 alert when merging a5bb3eb into a493c95 - view on LGTM.com new alerts:
|
I've been testing this PR in https://github.com/rgommers/scipy/tree/meson, which starts porting SciPy submodules to Meson. So far everything works as expected. |
I think we'll need to solve #8725 to completely make cython a 1st class language, but I'm glad this is step in the right direction. |
@@ -1757,6 +1759,30 @@ def detect_cs_compiler(self, for_machine): | |||
|
|||
self._handle_exceptions(popen_exceptions, compilers) | |||
|
|||
def detect_cython_compiler(self, for_machine: MachineChoice) -> CythonCompiler: | |||
"""Search for a cython compiler.""" | |||
compilers = self.lookup_binary_entry(for_machine, 'cython') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether this should better use the cython
or the cythonize
frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure it must be cython
. Parallel builds, caching, etc. should come from Meson not Cython, and we want Meson to invoke the C/C++ compiler rather than have Cython use setuptools under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to build on cython
not cythonize
, we can easily generate a .pyx -> .c rule and a second .c -> .o rule ourselves. Vala already works this way.
How useful would this be in the main tree without the generated code bits? I.e. could that be dropped from this MR's scope and added afterwards? |
I could fix the generated code bits to at least be on par with Rust pretty easily, ie you could have a purely generated or purely static build, but not a mix. I would be happy to land this at that point, and we can finish the structured input stuff separately. Let me update this today. |
a5bb3eb
to
ef5327f
Compare
This is now based on #8735 |
So, the only things that don't work currently that probably should are:
|
This pull request introduces 1 alert when merging ef5327f into 4ca9a16 - view on LGTM.com new alerts:
|
5f1ab76
to
e1e1e2a
Compare
This is something that the directive
The can always be changed per-file with the |
26ad37b
to
3f0d023
Compare
I've added the an option for setting the python target (2 vs 3). I've called it |
For C vs C++ I have something that works, but I have some annoying corners to sort out. |
@rgommers, for y'all how important is C++ support? I.e, can we land support for cython without it and get back to that later? |
It's a small percentage of all files, so seems fine to land without it - we can still use Here is the list of files containing
Here is the list of all our Cython files:
|
The |
Is there a reason not to use the |
Not sure I agree with that. |
Only if you ask it to build a complete extension module for you. If you just invoke it like |
Ah, didn't realize that. It seems to be missing flags though, like |
Oh, yeah, right. That sort-of goes against the idea of a "here's a bunch of files, do the right thing" kind of tool. Single file compilation is the normal case for For the include path, there's |
What's the current plan on getting this merged? |
I need to get the CI passing, then it's ready from my point of view |
They're not 100% complete, but it's mostly there.
Since cython transpiles to C.
92f86e3
to
0bc18f2
Compare
@rgommers is this looking good for you? |
Awesome to have this merged. Thanks @dcbaker, all! |
This is a follow-up to mesonbuildgh-8706, which contained the initial fix to ninjabackend.py but somehow lost it. This re-applies the fix and adds a test for it. Without the fix, the error is: ninja: error: 'ct2.pyx', needed by 'libdir/ct2.cpython-39-x86_64-linux-gnu.so.p/ct2.pyx.c', missing and no known rule to make it
This is a follow-up to gh-8706, which contained the initial fix to ninjabackend.py but somehow lost it. This re-applies the fix and adds a test for it. Without the fix, the error is: ninja: error: 'ct2.pyx', needed by 'libdir/ct2.cpython-39-x86_64-linux-gnu.so.p/ct2.pyx.c', missing and no known rule to make it
Okay, I stopped thinking about it and started writing code. This is not complete, there's a fair number of things not done (listed below). Currently, this is just enough to build one trivial test case, but I think it touches all the places that need to be changed, even if there is more work to do. I'm not sure how much more time I'll be able to spend on this, but here's a starting point if someone else wants to take it up.
TODO: