Skip to content

py_grpcio: Patch the setup.py to only link against the spack provided abseil#3107

Open
mmancini-skao wants to merge 8 commits intospack:developfrom
mmancini-skao:bugfix/py_grpcio_and_system_abseil-cpp
Open

py_grpcio: Patch the setup.py to only link against the spack provided abseil#3107
mmancini-skao wants to merge 8 commits intospack:developfrom
mmancini-skao:bugfix/py_grpcio_and_system_abseil-cpp

Conversation

@mmancini-skao
Copy link

This pull request introduces an update to the patching logic for the py_grpcio package to improve compatibility with custom installation prefixes for the abseil-cpp dependency. The change ensures that the build process correctly locates shared libraries in the appropriate directory, rather than assuming a system path.

Dependency patch improvement:

  • Updated the patch method in py_grpcio/package.py to replace a hardcoded search for libabsl_*.so in /usr with a dynamic search in the spack abseil-cpp library prefix.

@mmancini-skao mmancini-skao force-pushed the bugfix/py_grpcio_and_system_abseil-cpp branch 2 times, most recently from 91614dd to eec81d7 Compare January 23, 2026 18:15
@mmancini-skao mmancini-skao force-pushed the bugfix/py_grpcio_and_system_abseil-cpp branch from eec81d7 to 38f08cb Compare January 23, 2026 18:33
@mmancini-skao mmancini-skao changed the title Patch the setup.py to only link against the spack provided abseil py_grpcio: Patch the setup.py to only link against the spack provided abseil Jan 26, 2026
Copy link
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

A bit similar to @haampie's recent #3354.

@Giuncan
Copy link
Contributor

Giuncan commented Feb 24, 2026

Hi @mmancini-skao , I compiled this package different times, changing version and/or dependecies but I always got an runtime error regarding undefined symbol: _ZN4absl12lts_2024072210IsNotFoundERKNS0_6StatusE when I tried to import grpc.

With your first patch, I still had the same issue because the prefix.lib folder that you were using:

self.spec["abseil-cpp"].prefix.lib

does not exist in my abseil-cpp@20240722 spack installation (as also highlighted by @adamjstewart). Indeed, the original setup.py code use a wildcard also for the library folder: lib*/.

My suggestion is to simplify and generalize your filter_file in this way:

            filter_file(
                r'pathlib.Path("/usr")',
                r'pathlib.Path("{}")'.format(self.spec["abseil-cpp"].prefix),
                "setup.py",
                string=True,
            )

Today I saw that the patch is changed, and now the path lib should exist because you are using self.spec["abseil-cpp"].libs[0]. However, why should we use only the first library? In the original setup.py it loops over all the possible libraries.

Cheers

@mmancini-skao
Copy link
Author

Thank you for both your comments @Giuncan and @adamjstewart!
In the last commit I think I should be covering both the problem of the .so and .dynlib as well as the fact that the .lib folder does not exist on some systems.

Unfortunately, @Giuncan your patch wouldnt work for the dynlib.
To generalize the approach I also tried to use the .libs as a list to pass to the sorted in the setup.py but that didnt work on our system (ubuntu 22.04) as the .libs was empty.
I tested it by running

spack fetch py-grpcio
spack patch py-grpcio
spack cd py-grpcio

making sure that abseil-cpp was already installed.

Most probably I am missing something. Let me know what you think.

@mmancini-skao mmancini-skao force-pushed the bugfix/py_grpcio_and_system_abseil-cpp branch from 76f8b16 to e5d2a39 Compare February 24, 2026 09:20
@mmancini-skao mmancini-skao force-pushed the bugfix/py_grpcio_and_system_abseil-cpp branch from e5d2a39 to 035b967 Compare February 24, 2026 09:30
@adamjstewart
Copy link
Member

To generalize the approach I also tried to use the .libs as a list to pass to the sorted in the setup.py but that didnt work on our system (ubuntu 22.04) as the .libs was empty.

Can we fix this?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants