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

Add support for pybind11 Smart_holder branch #269

Merged
merged 5 commits into from
Oct 26, 2023

Conversation

kliegeois
Copy link
Contributor

@kliegeois kliegeois commented Oct 17, 2023

This PR adds support for the pybind11 smart_holder branch as discussed in #263. @lyskov

Copy link
Member

@lyskov lyskov left a comment

Choose a reason for hiding this comment

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

Thank you for putting this together @kliegeois ! Looks good to me!

-- Could you please add minimal documentation for a new option? I think it would be great if it links to #263 as well as to smart-holder Pybind11 branch.
Thanks,

#include <sstream> // __str__

#include <functional>
#include <pybind11/smart_holder.h>
Copy link
Member

Choose a reason for hiding this comment

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

Right now this test will fail since there is no smart_holder.h header in our Pybind11 fork... 🤔 - any thoughts how we can workaround this? Looking at https://github.com/pybind/pybind11/blob/smart_holder/include/pybind11/smart_holder.h it seems that it does include original pybind11.h but it is not clear why developers have decided to create separate header...

To get started, I see at least the following ways we can work around this issue:
[a] add smart_holder.h symlink pointing to original file to our current Pybind11 fork, - sounds like a error prone solution with some maintenance overhead
[b] somehow mark this particular test as "special" so compilation failure is ignored
[c] allow user to specify which include to use in place of smart_holder.h and instruct test to override that to use standard header

@kliegeois thoughts on this? I am leaning toward [b] unless some there an elegant solution that I missing...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer the option [b], I think it is the cleanest option.

Copy link
Member

Choose a reason for hiding this comment

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

@kliegeois I gave this more thoughts and I think I have better idea: how about if we add one more config directive: pybind11_include_file to allow user to customize it and in the same time remove automatic changing pybind11_include_file value when one or more smart_holder config options was specified? - I think that will give very nice and predictable behavior as well as expand possible code use (for example if for some reason someone need to use different pybind11 header for other reasons). And in the same time this will allow us to fully run the test. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

And if we go with above changes then please also note that pybind11_include_file config option will need short description in documentation. Thanks,

@kliegeois
Copy link
Contributor Author

Thanks @lyskov for the review!

I will add the documentation as requested.

@kliegeois kliegeois requested a review from lyskov October 19, 2023 20:32
@@ -52,6 +52,7 @@ class Config
string default_member_rvalue_reference_return_value_policy_ = "pybind11::return_value_policy::automatic";
string default_call_guard_ = "";
string holder_type_ = "std::shared_ptr";
string include_file_ = "pybind11/pybind11.h";
Copy link
Member

Choose a reason for hiding this comment

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

Could you please rename this to something like pybind11_include_file_? Otherwise name will be quite confusing (ie include file for what?) since we talk about includes all over Binder code. Thanks,

@@ -90,6 +91,7 @@ class Config
string const &prefix_for_static_member_functions() { return prefix_for_static_member_functions_; }

string const &holder_type() const { return holder_type_; }
string const &include_file() const { return include_file_; }
Copy link
Member

Choose a reason for hiding this comment

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

same as above: could you please rename this to pybind11_include_file to avoid confusion? Thanks,

#include <sstream> // __str__

#include <functional>
#include <pybind11/smart_holder.h>
Copy link
Member

Choose a reason for hiding this comment

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

@kliegeois I gave this more thoughts and I think I have better idea: how about if we add one more config directive: pybind11_include_file to allow user to customize it and in the same time remove automatic changing pybind11_include_file value when one or more smart_holder config options was specified? - I think that will give very nice and predictable behavior as well as expand possible code use (for example if for some reason someone need to use different pybind11 header for other reasons). And in the same time this will allow us to fully run the test. Thoughts?

#include <sstream> // __str__

#include <functional>
#include <pybind11/smart_holder.h>
Copy link
Member

Choose a reason for hiding this comment

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

And if we go with above changes then please also note that pybind11_include_file config option will need short description in documentation. Thanks,

@kliegeois kliegeois requested a review from lyskov October 25, 2023 02:53
@kliegeois
Copy link
Contributor Author

Thanks for the review @lyskov !
I updated the PR as suggested.

Copy link
Member

@lyskov lyskov left a comment

Choose a reason for hiding this comment

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

LGTM!

@lyskov
Copy link
Member

lyskov commented Oct 26, 2023

@kliegeois thank you for putting this together! I really like how this is implanted now, - will merge this shortly!

@lyskov lyskov merged commit ccafcfb into RosettaCommons:master Oct 26, 2023
11 checks passed
This was referenced Oct 26, 2023
ldedier-gpfw pushed a commit to G-P-S/binder that referenced this pull request Sep 16, 2024
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