-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make no-python build ABI compatible with python build #1729
Make no-python build ABI compatible with python build #1729
Conversation
Filed as internal issue #USD-7107 |
Hi @foisya-adsk ! We want to integrate this, but we do not have you listed in Autodesk's CLA. Can you please ask Gordon to add you? Thank you!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left questions about the need for TfPyBoostObjWrapper vs the existing TfPyObjWrapper. Thanks!
pxr/base/tf/anyWeakPtr.h
Outdated
#ifdef PXR_PYTHON_SUPPORT_ENABLED | ||
TF_API virtual boost::python::api::object GetPythonObject() const; | ||
#endif // PXR_PYTHON_SUPPORT_ENABLED | ||
TF_API virtual TfPyBoostObjWrapper GetPythonObject() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any particular reason why a separate TfPyBoostObjWrapper is needed here instead of using the existing TfPyObjWrapper? It looks like other code like VtValue is using TfPyObjWrapper, so it seems like it should be usable here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! When we did the changes we wanted to keep things as separate as possible and we kept the return types the same as the ones we wrapped. We will do as you suggest and unify under TfPyObjWrapper.
I think we we were too cautious when considering boost::python::object and boost::python::api::object... One is a "using ..." of the other! We will simplify things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other difference between the two uses is is that TfPyObjWrapper is holding a shared_ptr to an object. However, object is basically a reference-counted holder as well, so it should have the same semantic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other difference between the two uses is is that TfPyObjWrapper is holding a shared_ptr to an object. However, object is basically a reference-counted holder as well, so it should have the same semantic.
The big important reason why this class exists and uses a shared_ptr is that in order to use boost::python::object you have to be holding the python GIL, since it invokes the python ref-counting operations under the hood, and boost::python::object does not take the GIL itself. This is explained in the class doc for TfPyObjWrapper (https://graphics.pixar.com/usd/release/api/class_tf_py_obj_wrapper.html#details)
Provides a wrapper around boost::python::object that works correctly for the following basic operations regardless of the GIL state: default construction, copy construction, assignment, (in)equality comparison, hash_value(), and destruction.
None of those work correctly in the presence of an unlocked GIL for boost::python::object. This class only actually acquires the GIL for default construction, destruction and for some (in)equality comparisons. The other operations do not require taking the GIL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is worth noting that in the latest commit, in which we use only the wrapper class TfPyObjWrapper, there will be a small overhead when creating the TfPyObjWrapper and deleting it. For example:
`TfPyObjWrapper. TfAnyWeakPtr::_PointerHolder<Ptr>::GetPythonObject() `
will return a TfPyObjWrapper
and a subsequent call to the Get()
method of a TfPyObjWrapper
object will return the boost::python::object
.
Thus, on the one hand, there is small cost when going through TfPyObjWrapper
, and, on the other hand, it is protected because of the pointer management of TfPyObjWrapper
.
Is that OK?
pxr/base/tf/pyBoostObjWrapper.h
Outdated
/// usable when python extensions are accessible | ||
/// and when no python extensions are compiled | ||
#ifdef PXR_PYTHON_SUPPORT_ENABLED | ||
class TfPyBoostObjWrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason we need both TfPyBoostObjWrapper and TfPyObjWrapper? We weren't sure if there was something important we were missing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, except that we we wanted to isolate the "proposed changes" as much as possible. We will consolidate the code under TfPyObjWrapper...
This change makes sure client compiling against builds with Python support disabled can still run their application with a runtime USD with Python enabled. This is mainly done by wrapping Python binding types in a wrapper which has the same size and alignment in no-python builds, using pyObjWrapper.h. Co-authored-by: Martin Bisson <[email protected]>
002caba
to
15b0f8b
Compare
Martin and I just pushed an updated version with no extra TfPyBoostObjWrapper |
@spiffmon Thanks to Gordon, my CLA status has been cleared. |
Yes! We'll definitely get this in for the next release!
…--spiff
On Thu, Mar 3, 2022 at 3:41 PM Andre Foisy ***@***.***> wrote:
@spiffmon <https://github.com/spiffmon> Thanks to Gordon, my CLA status
has been cleared.
—
Reply to this email directly, view it on GitHub
<#1729 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPOU2BPZIDIFAAIP7WEWXDU6FE2VANCNFSM5LIERVAQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Just to report that building on Apple clang version 13.0.0 (clang-1300.0.29.30) I get a runtime crash where
|
@MrKepzie That sounds concerning. Were you running into this in a build with Python enabled or disabled? If you have more details it'd be great if you could file an issue so we can dig into it. |
Build without python. I was paranoid and thought it was picking up another dylib at runtime, but no this was the one I compiled. Will file an issue |
…plugin to load in 2023
Description of Change(s)
This change makes sure clients compiling against builds with Python
support disabled can still run their application with a runtime USD
with Python enabled.
This is mainly done by wrapping Python binding types in wrappers which
have the same size and alignment in no-python builds.
This is mainly done in existing pyObjWrapper.h and new
pyBoostObjWrapper.h. For example, the applied pattern looks like:
Fixes Issue(s)
Co-authored-by: Martin Bisson [email protected]