-
Notifications
You must be signed in to change notification settings - Fork 40
[config] Modernize cython module compilation #3334
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
[config] Modernize cython module compilation #3334
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe PR refactors the Cython build in setup.py: imports Sequence Diagram(s)(omitted — conditions for diagram generation not met) Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 🧪 Unit Test Generation v2 is now available!We have significantly improved our unit test generation capabilities. To enable: Add this to your reviews:
finishing_touches:
unit_tests:
enabled: trueTry it out by using the Have feedback? Share your thoughts on our Discord thread! Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@setup.py`:
- Around line 120-128: The Extension in setup.py is named "img_fast" but should
use the full package path so the compiled module lands in the package namespace;
update the Extension call that currently sets the name "img_fast" to
"odemis.util.img_fast" (i.e., change the first argument of Extension) so Cython
builds the module into the odemis.util package and imports like
odemis.util.img_fast (used by img.py and img_test.py) will succeed.
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.
Pull request overview
Modernizes the build configuration for the Cython-based image conversion module to reduce compile-time warnings (NumPy deprecated API) and clarify exception behavior.
Changes:
- Mark
cDataArray2RGBasnoexceptin the Cython implementation. - Switch
setup.pyto define a CythonExtensionexplicitly and setNPY_NO_DEPRECATED_APIto avoid deprecated NumPy C-API usage warnings. - Adjust
cythonize()invocation to use the definedExtensionlist.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/odemis/util/img_fast.pyx |
Declares the core nogil conversion helper as noexcept. |
setup.py |
Introduces an explicit Extension configuration for Cython build and adds NumPy deprecation macro. |
c3675fe to
adf17a0
Compare
Remove usage of old numpy API. Define the cython module in a separate setuptool command. In practice, this doesn't seem to yield any performance change. Just less warnings when compiling the cython module. Add comment to indicate the cDataArray2RGB will not raise any exception. This would improve performance (~30% faster)... but only works on Ubunut 24.04, so for now disabled.
adf17a0 to
aa00a00
Compare
Remove usage of old numpy API.
Define the cython module in a separate setuptool command.
In practice, this doesn't seem to yield any performance change. Just less warnings when compiling the cython module.
Add comment to indicate the cDataArray2RGB will not raise any exception.
This would improve performance (~30% faster)... but only works on Ubunut 24.04, so for now disabled.