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

Matlab wrapper uses python 3 #519

Closed
mfinean opened this issue Sep 11, 2020 · 7 comments · Fixed by #526
Closed

Matlab wrapper uses python 3 #519

mfinean opened this issue Sep 11, 2020 · 7 comments · Fixed by #526
Labels
bug Bug report

Comments

@mfinean
Copy link

mfinean commented Sep 11, 2020

Problem:
[ 56%] Generating wrap/gtsam/gtsam_wrapper.cpp
Ignoring classes: ['gtsam::Point2', 'gtsam::Point3']
Traceback (most recent call last):
File "/path/gtsam/wrap/matlab_wrapper.py", line 1770, in
cc_content = wrapper.wrap()
File "/path/gtsam/wrap/matlab_wrapper.py", line 1657, in wrap
self.wrap_namespace(self.module)
File "/path/gtsam/wrap/matlab_wrapper.py", line 1096, in wrap_namespace
self.wrap_namespace(element, namespaces)
File "/path/gtsam/wrap/matlab_wrapper.py", line 1101, in wrap_namespace
class_text = self.wrap_instantiated_class(element, "".join(namespace.full_namespaces()))
File "/path/gtsam/wrap/matlab_wrapper.py", line 1037, in wrap_instantiated_class
).splitlines()) + '\n'
File "/path/gtsam/wrap/matlab_wrapper.py", line 698, in wrap_class_constructors
methods_wrap = textwrap.indent(textwrap.dedent("""\

To generate the Matlab wrapper it requires python 3. I fixed by changing "Default" to my python 3 version.

set(GTSAM_PYTHON_VERSION "Default" CACHE STRING "The version of Python to build the wrappers against.")

@ProfFan
Copy link
Collaborator

ProfFan commented Sep 11, 2020

Ahh. Should be compatible with Python 2.7... #TODO

@ProfFan ProfFan added the bug Bug report label Sep 11, 2020
@varunagrawal
Copy link
Collaborator

I disagree that it should be compatible with Python 2.x.

Python 2 has officially reached EOL, so I recommend @mfinean upgrade his Python to 3.6+.

@varunagrawal
Copy link
Collaborator

Actually disregard my previous comment. This issue doesn't seem to have anything to do with Python 2.
@mfinean it seems that you haven't pasted the full stack trace and error message. Can you please do so?

@mfinean
Copy link
Author

mfinean commented Sep 11, 2020

My apologies that it cut off! First error encountered was:


[ 56%] Generating wrap/gtsam/gtsam_wrapper.cpp
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 87
print(message, file=sys.stderr)
^
SyntaxError: invalid syntax
gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/build.make:76: recipe for target 'gtsam/wrap/gtsam/gtsam_wrapper.cpp' failed
make[2]: *** [gtsam/wrap/gtsam/gtsam_wrapper.cpp] Error 1
CMakeFiles/Makefile2:1188: recipe for target 'gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/all' failed
make[1]: *** [gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....


This should have been my warning but I used
from __future__ import print_function
to bypass that. The next error was:


[ 58%] Building CXX object examples/CMakeFiles/Pose3SLAMExampleExpressions_BearingRangeWithTransform.dir/Pose3SLAMExampleExpressions_BearingRangeWithTransform.cpp.o
Ignoring classes: ['gtsam::Point2', 'gtsam::Point3']
Traceback (most recent call last):
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 1769, in
cc_content = wrapper.wrap()
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 1656, in wrap
self.wrap_namespace(self.module)
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 1095, in wrap_namespace
self.wrap_namespace(element, namespaces)
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 1100, in wrap_namespace
class_text = self.wrap_instantiated_class(element, "".join(namespace.full_namespaces()))
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 1036, in wrap_instantiated_class
).splitlines()) + '\n'
File "/home/mark/installs/gtsam/wrap/matlab_wrapper.py", line 697, in wrap_class_constructors
methods_wrap = textwrap.indent(textwrap.dedent("""
AttributeError: 'module' object has no attribute 'indent'
gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/build.make:76: recipe for target 'gtsam/wrap/gtsam/gtsam_wrapper.cpp' failed
make[2]: *** [gtsam/wrap/gtsam/gtsam_wrapper.cpp] Error 1
CMakeFiles/Makefile2:1188: recipe for target 'gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/all' failed
make[1]: *** [gtsam/CMakeFiles/gtsam_matlab_wrapper.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....


I wasn't suggesting for it be made Python 2 compatible but rather that there could be a catch for this to ensure Python 3 is used. In my case, the default was still Python 2.

@varunagrawal
Copy link
Collaborator

Ah thanks a lot! So you're right, in that Default picks up Python 2 on your system (I am guessing you are using Ubuntu?). Setting the CMake variable GTSAM_PYTHON_VERSION (either via command line or ccmake) to 3.6 or whatever version of python you are using, should fix this issue as you have already discovered.

I guess the issue really is that we need to somehow enforce Python 3+ in the wrapper. @ProfFan

@varunagrawal
Copy link
Collaborator

@mfinean #526 uses CMake to find Python3 exclusively. This should solve this issue.

Can you checkout that PR and try it on your local machine to confirm?

@varunagrawal
Copy link
Collaborator

@mfinean PR #526 has been merged into develop. Can you please confirm it solves this issue for you?
If not, please feel free to reopen the issue.

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

Successfully merging a pull request may close this issue.

3 participants