-
Notifications
You must be signed in to change notification settings - Fork 280
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 tf2_py compatible with python3. #173
Conversation
This should fix #50, btw. |
One more addendum: Rewriting the whole thing in Cython seems like a good idea to me, perhabs even with a more full-featured API (while maintaining backwards compatibility of course). However, I wanted python3 compatibility fast, and this was the quickest, least intrusive way to get that. |
@ros-pull-request-builder retest this please Thanks for the contribution. I'll try to review it tomorrow. Python3 support will be great. |
Thanks for taking the time to do this. It looks good to me. Bumping Thanks for working around it without the extra dependency. If this is enough lets stick with this and not completely refactor it to Cython. |
Moved (Update: And made it inline, since it is defined in a header.) Thanks for the review. |
Thanks again! |
Thank you for this patch! |
Hi folks, will there be anytime soon release of geometry2 with this patch? |
@SquirrelCZE I'm wondering the same thing. In the meantime, I built from source based on the latest version I just pulled (439e235), but I can't figure out how to actually use TF2 in Python 3. Here's what I did:
Then I tried to use it with
|
I should say the import error is the same (except for paths) I get when only working with the latest version installed from APT. |
Have you solved this ??? Coming from the future :D |
This PR makes tf2_py compatible with python3. I compiled the package for both python 3.5 and 2.7 (which worked), but I did not test the resulting python module.
There were three issues to fix:
I put wrapper functions for the correct string types in
python_compat.h
(and one convenience function for importing modules). Something similar could be done for the type definition and the module initialization, but those would involve writing new macros, which would not necessarily make the code easier to maintain (especially in the case of module initialization).I did not use
py3c
(a C API compatibility layer for python2/3) to avoid adding a new dependency. If a new dependency is acceptable,py3c
would be a good alternative. It would involve adding a new rosdep key though, I assume.If this is the way to go,
PyObject_BorrowAttrString
could also be moved topython_compat.h
, to group python convenience functions together. (Though I would rename it so it doesn't look like a real python function. It took me a while of digging through the python C API before realising it is defined in the source file itself).