Abseil migration#1270
Merged
Merged
Conversation
Collaborator
Author
|
Python wrapper error is expected. we need to aligned with the project #1266 |
- Replaced sentencepiece::util::Status/StatusCode with absl::Status/StatusCode globally in src/. - Removed custom Status implementation in src/error.cc (deleted). - Included absl/status/status.h in public headers sentencepiece_processor.h and sentencepiece_trainer.h (using third_party/absl/ path in source tree). - Updated src/CMakeLists.txt to link absl::status publicly for shared libraries. - Added cmake/modify_headers.cmake to transform public headers during installation to use <absl/...> includes. - Updated utility macros (DECLARE_ERROR, RET_CHECK, StatusBuilder) and test harness (EXPECT_OK) to work with absl::Status. - Fixed nodiscard warnings in sentencepiece_trainer_test.cc. - Added explicit includes (e.g., <absl/status/status.h>, <absl/strings/string_view.h>) to all files using these types directly to comply with IWYU. - Formatted all modified C++ files using clang-format -style=Google, sorting includes. - Updated SWIG wrapper python/src/sentencepiece/sentencepiece.i and helper header python/src/sentencepiece/sentencepiece_swig.h to use absl::Status/StatusCode. - Updated python/setup.py to include Abseil headers directory and repo root in compiler include paths. - Updated python/src/sentencepiece/sentencepiece_wrap.cxx to match the absl::Status migration.
cf5aefc to
39279bf
Compare
- Updated .github/workflows/wheel.yml to copy C++ source files into python/sentencepiece directory before running cibuildwheel. - This ensures cibuildwheel uses the local modified C++ sources rather than cloning the upstream master branch, preventing compilation errors due to API mismatches during migration.
4f626dc to
34cc226
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates SentencePiece's internal custom status wrapper (
sentencepiece::util::StatusandStatusCode) to standardabsl::Statusandabsl::StatusCodefrom the Abseil library.This cleanup reduces custom code maintenance, aligns the project with modern C++ standards, and makes it easier to integrate SentencePiece into projects that already use Abseil.
Key Changes
src/error.ccand removed it from the build. Deleted the customStatusandStatusCodedefinitions fromsentencepiece::utilinsrc/sentencepiece_processor.h.util::Status->absl::Status,util::StatusCode->absl::StatusCode, andutil::OkStatus()->absl::OkStatus()across all C++ source and test files.absl::statustoSPM_LIBSinsrc/CMakeLists.txt.target_link_librariesfor shared libraries (sentencepieceandsentencepiece_train) to usePUBLIClinking, exposing the Abseil dependency to consumers.cmake/modify_headers.cmaketo automatically replace internal"third_party/absl/..."includes with standard<absl/...>includes when installing public headers (sentencepiece_processor.handsentencepiece_trainer.h).EXPECT_OKandEXPECT_NOT_OKinsrc/testharness.hto useabsl::Status::ok().nodiscardwarnings insentencepiece_trainer_test.cc.sentencepiece_processor_benchmarks_test.ccto work with the migrated status types.Testing Done
SPM_BUILD_TEST=ONandSPM_ENABLE_BENCHMARK=ON.ctestand confirmed 100% pass rate.cmake --install) and verified that the installed headers ininclude/correctly contain<absl/status/status.h>instead of"third_party/absl/status/status.h".