ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
2

how is the PYTHON_EXECUTABLE variable/option is set with catkin? how can i set its default?

asked 2014-01-04 02:16:11 -0600

Edno gravatar image

updated 2014-01-28 17:18:57 -0600

ngrennan gravatar image

I know that the "python-problem" in arch linux is already known, and i don't like it. I've managed to install ros-hydro from source in my arch, which took a lot of time for me. I've replaced all calls to python for a explicit python2 call with grep and sed, like this:

grep -rl ./ "/bin/env python" | xargs sed -i 's/env python/env python2/g'

"#!/bin/env python" -> "#!/bin/env python2".

But, even with that, i had to set the option -DPYTHON_EXECUTABLE=python2 manually on the command line. I've tried to figure out how i could set some kind of default in the sources, so i put this line on the "python.cmake" file, in catkin/cmake/:

set(PYTHON_EXECUTABLE python2).

that works fine, but it just doesn't seem the correct way to do it, because if i do the following to build ros: ./src/catkin/bin/catkin_make_isolated -DPYTHON_EXECUTABLE=python3.3 for example, it builds normally, like if PYTHON_EXECUTABLE option became constant somehow.

could someone explain me how this variable is set, and how i could make this solution seem more "correct"... and, why doesn't the official sources make explicit calls for python2, instead of python? wouldn't that make ros more portable? I also don't like the way it feels like the only supported platform is ubuntu.

edit retag flag offensive close merge delete

Comments

@Dirk Thomas I retagged this if you didn't get the notification.

tfoote gravatar imagetfoote ( 2014-01-05 19:25:28 -0600 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2014-01-06 05:39:43 -0600

Dirk Thomas gravatar image

updated 2014-01-06 09:34:51 -0600

The upcoming version of catkin allows you to consistently set the Python version being used within the build process (https://github.com/ros/catkin/issues/570). Therefore you have to specify the option -DPYTHON_VERSION=3.3 when invoking CMake the first time (the number refers to the suffix of the python executable, it could also be 3 only). This will address that all scripts during the build process are invoked with a specific Python version and packages which link against the Python libraries can pick the correct library version.

While Python scripts installed by the setup.py file have their shebang lines updated automatically other scripts installed from CMake are currently not updated like that. We will work on a CMake function which will perform the same shebang rewriting for files installed using this new function (https://github.com/ros/catkin/pull/574).

Regarding the "default" shebang line ROS is currently neither Ubuntu specific nor will we change the default invocation to python2. The "problem" here is that arch is actually not following the official Python guidelines described in http://www.python.org/dev/peps/pep-0394/ It clearly states that python should always point to a Python 2 interpreter (for very good reasons). ROS will follow this recommendation which is used by most of the distributions.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-01-04 02:16:11 -0600

Seen: 2,747 times

Last updated: Jan 06 '14