-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[CppExtension] Extract get paddle include dirs logic to a common method #74994
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
[CppExtension] Extract get paddle include dirs logic to a common method #74994
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
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
This PR extracts the logic for getting Paddle include directories into a common method to avoid code duplication across multiple files. The change introduces _get_all_paddle_includes_from_include_root() function and replaces repetitive include directory collection code in test files.
- Introduces a new helper function
_get_all_paddle_includes_from_include_root()in extension_utils.py - Refactors multiple test files to use the new common method instead of duplicated include path logic
- Removes some unused imports and simplifies path construction in several places
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/paddle/utils/cpp_extension/extension_utils.py | Adds the new helper function and refactors existing find_paddle_includes to use it |
| test/deprecated/custom_op/utils.py | Replaces duplicated include path logic with the new helper function |
| test/custom_runtime/test_custom_op_setup.py | Uses the new helper function for include path collection |
| test/custom_op/utils.py | Replaces duplicated include path logic with the new helper function |
| test/custom_kernel/test_custom_kernel_load.py | Simplifies site packages path collection |
| test/cpp_extension/utils.py | Uses the new helper function for include path collection |
| test/cpp_extension/test_cpp_extension_jit.py | Replaces duplicated include path logic with the new helper function |
| test/cpp_extension/cpp_extension_setup.py | Uses the new helper function for include path collection |
| test/auto_parallel/semi_auto_parallel_simple_net_custom_relu.py | Replaces duplicated include path logic with the new helper function |
| test/auto_parallel/semi_auto_parallel_for_custom_relu.py | Uses the new helper function for include path collection |
| test/auto_parallel/custom_op/utils.py | Replaces duplicated include path logic with the new helper function |
| python/paddle/base/core.py | Simplifies site packages path collection |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| def _get_all_paddle_includes_from_include_root(include_root: str) -> list[str]: | ||
| """ | ||
| Return Paddle necessary include dir path. | ||
| Get all paddle include directories from include root (packaged in wheel) |
Copilot
AI
Aug 31, 2025
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.
The function is missing a docstring that explains its parameters and return value. Consider adding documentation for the include_root parameter to clarify its expected format and purpose.
| from paddle.utils.cpp_extension.extension_utils import ( | ||
| _get_all_paddle_includes_from_include_root, |
Copilot
AI
Aug 31, 2025
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.
The function _get_all_paddle_includes_from_include_root is marked as private with a leading underscore but is being imported and used across multiple test files. Consider making it a public API by removing the underscore prefix or keeping it private and accessing it through a public interface.
| from paddle.utils.cpp_extension.extension_utils import ( | |
| _get_all_paddle_includes_from_include_root, | |
| get_all_paddle_includes_from_include_root, |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #74994 +/- ##
==========================================
Coverage ? 75.00%
==========================================
Files ? 2
Lines ? 8
Branches ? 0
==========================================
Hits ? 6
Misses ? 2
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|


PR Category
Execute Infrastructure
PR Types
Deprecations
Description
将获取所有 includes 提取成公共函数以免调整后需要修改 10 多处,resolves #74402 (comment)
另外 Python 3.2+
site一定包含getsitepackages方法1,因此移除相关判断Footnotes
https://docs.python.org/3/library/site.html#site.getsitepackages ↩