Skip to content

[Python] Fix absl sources in setup.py for system absl#41885

Open
sreenithi wants to merge 1 commit intogrpc:masterfrom
sreenithi:fix_absl_init_log_system_absl
Open

[Python] Fix absl sources in setup.py for system absl#41885
sreenithi wants to merge 1 commit intogrpc:masterfrom
sreenithi:fix_absl_init_log_system_absl

Conversation

@sreenithi
Copy link
Copy Markdown
Contributor

Fixes #41696

@sergiitk sergiitk added the release notes: no Indicates if PR should not be in release notes label Mar 17, 2026
@sergiitk
Copy link
Copy Markdown
Member

/gemini review

Comment thread setup.py
Comment on lines +356 to +359
system_absl_path = os.path.join("/usr", "include")
ABSL_INCLUDE = (system_absl_path,)
ABSL_SOURCES = [
p.replace("third_party/abseil-cpp", system_absl_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
system_absl_path = os.path.join("/usr", "include")
ABSL_INCLUDE = (system_absl_path,)
ABSL_SOURCES = [
p.replace("third_party/abseil-cpp", system_absl_path)
_system_absl_path = os.path.join("/usr", "include")
ABSL_INCLUDE = (_system_absl_path,)
ABSL_SOURCES = [
p.replace("third_party/abseil-cpp", _system_absl_path)

Discussed f2f with @asheshvidyut

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies setup.py to introduce an ABSL_SOURCES variable for managing Abseil source file paths, enabling conditional use of system-installed Abseil. A critical issue was identified: when building with system Abseil, the ABSL_SOURCES list should be cleared to prevent incorrect compilation of source files from the system include path, as the system library should be linked directly.

Comment thread setup.py
Comment on lines +358 to +361
ABSL_SOURCES = [
p.replace("third_party/abseil-cpp", system_absl_path)
for p in ABSL_SOURCES
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

When building with system Abseil, we should be linking against the pre-compiled system library, not compiling its source files. The current logic attempts to locate and compile an Abseil source file from the system include path (/usr/include), which is incorrect.

The ABSL_SOURCES list should be cleared when BUILD_WITH_SYSTEM_ABSL is enabled.

    ABSL_SOURCES = []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a fair point.

grpc/setup.py

Lines 161 to 164 in 4f623df

# Export this variable to use the system installation of abseil. You need to
# have the header files installed (in /usr/include/absl) and during
# runtime, the shared library must be installed
BUILD_WITH_SYSTEM_ABSL = os.environ.get("GRPC_PYTHON_BUILD_SYSTEM_ABSL", False)

We don't expect sources to be present when the system absl is used, only headers.

Comment thread setup.py
Copy link
Copy Markdown
Member

@sergiitk sergiitk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini caught something important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.78.1: Error building Python wheel due to hardcoded dependency on vendored abseil

3 participants