-
Notifications
You must be signed in to change notification settings - Fork 0
chore: migrate to scikit-build-core #45
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
Conversation
WalkthroughThe changes in this pull request involve updates to the build configuration of a C++ project utilizing Python and Cython. The Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 5
🧹 Outside diff range and nitpick comments (5)
CMakeLists.txt (4)
1-7
: LGTM! Consider using a newer C++ standard.The initial setup looks good. The minimum CMake version, project name setup, and NumPy API version directive are all appropriate. However, you might want to consider using a newer C++ standard (e.g., C++14 or C++17) if your project doesn't require compatibility with older compilers, as newer standards offer additional features and improvements.
If you decide to use a newer C++ standard, you can update line 4 as follows:
-set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17)
10-19
: LGTM! Consider making OpenMP optional.The package finding section is well-structured and includes all necessary components for the project. The flexible OpenMP configuration using the OMP environment variable is a good approach. However, you might want to consider making OpenMP optional to increase the portability of your project.
You can make OpenMP optional by modifying the OpenMP finding as follows:
-find_package(OpenMP REQUIRED) +find_package(OpenMP) +if(OpenMP_FOUND) + add_definitions(-DUSE_OPENMP) +else() + message(STATUS "OpenMP not found. Building without OpenMP support.") +endif()Then, in your source code, you can use
#ifdef USE_OPENMP
to conditionally include OpenMP-related code.
22-27
: LGTM! Consider using find_package for NumPy.The current approach to retrieve the NumPy include directory is functional and ensures the correct directory is used. However, it might be more CMake-idiomatic to use
find_package
for NumPy if available in your CMake version.If your CMake version supports it, you could replace the current NumPy include directory retrieval with:
find_package(NumPy REQUIRED) include_directories(${NumPy_INCLUDE_DIRS})This approach is more consistent with CMake conventions and might be easier to maintain in the long run.
68-77
: LGTM! Consider making OpenMP linking conditional.The Cython transpilation and library creation for
_fast_unique
and_napari_mapping
follow the established pattern correctly. The linking with OpenMP is appropriate for potential performance improvements. However, to increase portability, consider making the OpenMP linking conditional.You can make the OpenMP linking conditional by modifying the target_link_libraries commands as follows:
-target_link_libraries(_fast_unique PRIVATE OpenMP::OpenMP_CXX) +if(OpenMP_FOUND) + target_link_libraries(_fast_unique PRIVATE OpenMP::OpenMP_CXX) +endif() -target_link_libraries(_napari_mapping PRIVATE OpenMP::OpenMP_CXX) +if(OpenMP_FOUND) + target_link_libraries(_napari_mapping PRIVATE OpenMP::OpenMP_CXX) +endif()This change ensures that the project can still be built on systems without OpenMP support.
src/PartSegCore_compiled_backend/calc_bounds.pyx (1)
Line range hint
1-218
: Summary of changes and recommendationsThe changes in this file involve updating the
components_num
parameter type fromPy_ssize_t
toint
in the function signatures ofcalc_bounds2
,calc_bounds3
,calc_bounds4
, andcalc_bounds5
. While this change improves consistency across function signatures, it introduces some inconsistencies within the functions themselves.Key points and recommendations:
- Update the docstrings for all affected functions to reflect the new
int
type forcomponents_num
.- Consider updating the implementation of each function to use
int
instead ofPy_ssize_t
for loop variables and array dimensions, for consistency with the function signatures.- Evaluate the impact of changing from
Py_ssize_t
toint
on the maximum supported array size and component count. Ensure that this change doesn't negatively affect the ability to handle large arrays or high component counts.- The main
calc_bounds
function is consistent with the changes and doesn't require modifications.Before merging these changes, it's crucial to:
- Thoroughly test the functions with various array sizes and component counts to ensure no regression in functionality.
- Update any related documentation or type hints in other parts of the codebase that may reference these functions.
- Consider adding a comment explaining the rationale behind changing from
Py_ssize_t
toint
, if there's a specific reason for this change.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- CMakeLists.txt (1 hunks)
- pyproject.toml (1 hunks)
- setup.py (0 hunks)
- src/PartSegCore_compiled_backend/calc_bounds.pyx (4 hunks)
💤 Files with no reviewable changes (1)
- setup.py
🧰 Additional context used
🔇 Additional comments (8)
pyproject.toml (2)
1-9
: Summary: Successful migration to scikit-build-coreThe changes in this file successfully implement the migration to scikit-build-core as intended. The
[build-system]
section has been updated appropriately, and a new[tool.scikit-build]
section has been added with the necessary configurations. These changes should improve the build process and integration with CMake.To ensure a smooth transition, please:
- Verify that all team members and CI systems have the required dependencies installed.
- Test the build process thoroughly in different environments.
- Update any documentation or README files to reflect the new build system requirements.
Great job on implementing this migration!
6-9
: LGTM! Verify CMake version requirement.The new
[tool.scikit-build]
section is well-configured for the scikit-build-core migration. The metadata version provider and sdist include settings are appropriate.Please verify that the CMake version requirement (>=3.21) is compatible with your development and CI environments:
#!/bin/bash # Description: Verify CMake version compatibility # Test: Check installed CMake version cmake --version # Test: Verify minimum required version if cmake --version | grep -q "cmake version 3.2[1-9]" || cmake --version | grep -q "cmake version 3.[3-9]" || cmake --version | grep -q "cmake version [4-9]"; then echo "CMake version is compatible" else echo "CMake version may not meet the minimum requirement" fiCMakeLists.txt (5)
30-43
: LGTM! Consistent and well-structured Cython transpilation.The Cython transpilation and library creation for
euclidean_cython
,path_sprawl_cython
, andsprawl_utils_cython
are implemented consistently and correctly. The use ofWITH_SOABI
ensures unique naming for the compiled modules, and the include directories are properly set to include both NumPy and local source directories.
46-55
: LGTM! Consistent implementation for additional Cython modules.The Cython transpilation and library creation for
fuzzy_distance_cython
andcolor_image_cython
follow the same consistent and correct pattern as the previous modules. Include directories are properly set, ensuring access to the necessary headers.
57-65
: LGTM! Consistent implementation with appropriate include directories.The Cython transpilation and library creation for
calc_bounds
andmso_bind
maintain the consistent pattern established in previous sections. The additional include directory formso_bind
is correctly set, ensuring access to the necessary headers in themultiscale_opening
subdirectory.
80-88
: LGTM! Well-organized installation structure.The installation commands are well-structured and ensure that each compiled module is placed in the correct location within the
PartSegCore_compiled_backend
package structure. This organization is consistent with the module names and likely reflects the desired package layout, which will facilitate proper importing and usage of the compiled modules.
1-88
: Overall, excellent CMakeLists.txt with minor suggestions for improvement.This CMakeLists.txt file sets up a comprehensive and well-structured build system for a Python/Cython project with C++ components. It effectively handles package finding, Cython transpilation, library creation, and installation. The consistency in handling multiple Cython modules is commendable.
To further improve the file, consider the following suggestions:
- Update to a newer C++ standard if backward compatibility is not a concern.
- Make OpenMP optional to increase portability.
- Use
find_package(NumPy)
instead ofexecute_process
if supported by your CMake version.- Make OpenMP linking conditional for
_fast_unique
and_napari_mapping
.These changes will enhance the flexibility and portability of your build system while maintaining its current functionality.
src/PartSegCore_compiled_backend/calc_bounds.pyx (1)
Line range hint
15-38
: Maincalc_bounds
function looks goodThe main
calc_bounds
function is consistent with the changes made to the dimension-specific implementations. It correctly usesOptional[int]
for thecomponents_num
parameter, which aligns with the updates made to the other functions.No changes are required for this function.
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: 0
🧹 Outside diff range and nitpick comments (3)
.gitignore (3)
Line range hint
1-6
: Consider refining ignore patterns for C++ and HTML files.The current ignore patterns for C++ source files (
*.cpp
) and HTML files (*.html
) might be too broad:
- Ignoring all C++ source files could potentially exclude important source code from version control.
- Ignoring all HTML files might not be necessary unless they are generated documentation.
Consider specifying more targeted patterns to ignore only generated or temporary files while keeping important source files under version control.
Line range hint
168-301
: Python ignore patterns are comprehensive but may include unnecessary entries.The Python-specific ignore patterns are extensive and cover most scenarios a Python project might encounter. This includes bytecode, distribution packages, virtual environments, and various tools, which is beneficial for maintaining a clean repository.
However, some patterns might be redundant or unnecessary depending on your project's specific needs. For example, there are ignores for Django, Flask, and Scrapy, which may not be relevant if your project doesn't use these frameworks.
Consider reviewing these patterns and removing any that are not applicable to your project to keep the .gitignore file as concise as possible.
Line range hint
1-301
: Overall, the .gitignore file is comprehensive and well-structured.This .gitignore file provides excellent coverage for various development environments, tools, and operating systems. It's based on a reputable template, which ensures it follows best practices.
To further improve it:
- Review the project-specific ignores at the beginning of the file to ensure they accurately reflect your project's needs.
- Consider removing ignore patterns for tools and frameworks that are not used in your project to keep the file concise.
- Periodically review and update this file as your project evolves to maintain its effectiveness.
Great job on implementing such a thorough .gitignore file!
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- .gitignore (1 hunks)
- CMakeLists.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- CMakeLists.txt
🧰 Additional context used
🔇 Additional comments (4)
.gitignore (4)
Line range hint
13-18
: VS Code ignore patterns look good.The VS Code ignore patterns follow best practices by excluding user-specific settings while allowing shared workspace configurations to be tracked. This approach promotes consistency across the development team.
Line range hint
20-30
: Jupyter Notebooks ignore patterns are appropriate.The ignore patterns for Jupyter Notebooks are comprehensive and follow best practices. Excluding checkpoint files and IPython configuration prevents unnecessary files from being tracked, which is beneficial for maintaining a clean repository.
Line range hint
32-85
: Operating system specific ignore patterns are comprehensive.The ignore patterns for Linux, macOS, and Windows are thorough and cover a wide range of system-generated files and directories. This comprehensive approach helps maintain a clean repository across different development environments.
Line range hint
87-166
: PyCharm and JetBrains IDE ignore patterns are well-structured.The ignore patterns for PyCharm and other JetBrains IDEs are extensive and follow best practices. They effectively exclude user-specific settings and generated files while allowing for potential shared configurations. The use of comments to explain certain choices (like auto-import related ignores) is particularly helpful and promotes understanding among team members.
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: 0
🧹 Outside diff range and nitpick comments (1)
pyproject.toml (1)
6-11
: LGTM! Consider adding a comment for the CMake version requirement.The new
[tool.scikit-build]
section is well-configured for the project's needs. It correctly sets up version metadata, sdist inclusions/exclusions, and wheel exclusions.Consider adding a comment explaining the reason for the CMake version requirement:
# Minimum CMake version required for the project cmake.version = ">=3.21"This helps future maintainers understand why this specific version was chosen.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- pyproject.toml (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
pyproject.toml (1)
3-4
: LGTM! Verify CMake installation.The changes to the
[build-system]
section correctly implement the migration to scikit-build-core as per the PR objective. The updatedrequires
list andbuild-backend
are appropriate for this transition.Please ensure that CMake is installed and available in the build environment, as it's essential for the new build system. Run the following script to verify:
Summary by CodeRabbit
New Features
euclidean_cython
,path_sprawl_cython
, and others.Bug Fixes
calc_bounds
functions to improve compatibility and performance.Chores
scikit-build-core
, enhancing build process efficiency.setup.py
file for streamlined project structure..gitignore
to exclude a wider range of development-related files and directories.