Skip to content
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

Fix/python service call encoding #63

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Aposhian
Copy link

Addresses #62

This also makes some tweaks to the generate-python.sh script, and also regenerates the pybind11 wrappers. The diff is larger than I would expect, so not sure if there is a mismatch in binder version or other settings. Happy to make changes as needed.

@jlblancoc jlblancoc self-requested a review January 17, 2025 00:41
Copy link
Member

@jlblancoc jlblancoc left a comment

Choose a reason for hiding this comment

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

Oh, good catch, thanks for the PR, @Aposhian !

I don't like including the pybind11 headers in the library public headers, but they are protected with a macro so as long as users w/o python don't get affected, it's good enough! There seems to be no alternative if one wants to use py::bytes 👍

Please, just make sure of passing clang-format script and check tabs vs spaces in cmake, and I'll glad to merge once CI is also happy.

@Aposhian
Copy link
Author

Ok, I ran the formatter script, and changed my tabs in my cmake additions to spaces.

I should have noted that I can see a few other ways to solve this problem and use py::bytes:

  • Put the py::bytes wrapper in a separate file that only gets pulled in by the python module build. This may or may not work well with the binder codegen?
  • write a custom type converter to force pybind11 to treat the string on that function as bytes. This seems the most nonstandard, and definitely would not play well with the binder codegen.

@Aposhian
Copy link
Author

The only way I can think of to make it work with splitting out the py::bytes function into a separate file is to subclass Client and have pybind11 bind to that instead of the original Client class. But I'm not sure how to not break backwards compatibility that way, at least not with the automatically generated code. Manually written bindings could probably do some renaming magic.

@jlblancoc
Copy link
Member

Ok, @Aposhian , don't worry about the "#include" in the header, as long as all CI pass we could live with that :-)

But please check the failing CI runs above. It's painful, but to support different versions of pybind with the same sources, I had to add some #if macros that were probably overwritten here. Please, look for:

#if (PYBIND11_MAJOR_VERSION == 2 && PYBIND11_MINOR_VERSION <= 4)

here, and apply that technique to all the places where the github actions above fail.

I'll approve the changes and leave this in "auto-merge" so once all CI tests pass, it won't require manual actions. Thanks!

@jlblancoc jlblancoc enabled auto-merge January 18, 2025 11:15
auto-merge was automatically disabled January 20, 2025 15:50

Head branch was pushed to by a user without write access

@Aposhian Aposhian marked this pull request as draft January 20, 2025 20:31
@Aposhian
Copy link
Author

Running into some issues with testing this. The imported symbol can't be resolved in the .so.

@jlblancoc
Copy link
Member

It's weird... I tested it to build OK locally. But "make test" fails with a protobuf error. Have you tried "make test" yourself too? If it fails, ctest --output-on-failure shows more info.

I feel it's close but... we'll have to carefully check all changes in the PR for the reason of this 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants