-
Notifications
You must be signed in to change notification settings - Fork 360
-
Notifications
You must be signed in to change notification settings - Fork 360
Python 2 and 3 compatibility #268
Comments
Many scripts in the package need to be Python 3 compatible, too. Apart from, for example, applying the suggested changes from ROS Python 2 and 3 compatibility, does anyone have any idea on how to automate tests for Python 2/3 compatibility in Travis CI? As far as I now, the images used there still have Python 2.7 as default. |
Any objections to using the python-future package https://python-future.org/ for compat? |
No, I am using it already in the Python code I write now to be sure it will work. My biggest concern is that I can't easily set up the CI system to actually run the tests and code with Python 3 automatically to see if it fails or not. |
Okay. Looking at the Travis CI runs, they take a long time (50+ minutes!) and seem to be timing out setting up the environment. I am not very familiar with Travis, but it does seem to allow using Docker images. If it's unable to set up the environment in a timely fashion maybe it should be migrated to use a Docker build environment, so it will build the env once and then cache it. ROS provides a number of docker files that could be built upon. |
Yes, I had to tweak some configurations because I was getting some errors (e.g. setting the maximum number of jobs to build the catkin workspace to 1), which also makes the process take a lot longer. |
Oh I see! I only looked at one failed build log and it terminated as it was configuring/installing dependencies. If it is a resources issue then docker is unlikely to solve it. The main reason I suggested Docker was that all the environment building can be done once and cached, so when Travis CI is triggered, it simply pulls a bunch of cached Docker images (this step should take seconds) and then it can instantly compile uuvsimulator and runs the tests.
I apologise if I am misunderstanding, is that a problem? It could be arranged with a number of docker containers: three 2.7 containers running kinetic, lunar and melodic and one melodic container running 3.6. And yes, the uuvsimulator-py36 dockerfile can pull in the python3 dependencies via apt-get, pip or rosdep quite easily. As for the actual tests, from what I have seen in other projects is they simply run the same unittests, but with the other python version, to test their code base. This will require decent code coverage to be successful. Unfortunately I do not have my workstation with me so I can't attempt to get a py3 environment running right this moment, hopefully I get it back sometime this weekend. |
I think you are right. Maybe setting up some of the builds to just do something like |
Hello @musamarcusso I am currently working with docker at the moment and will try to find some time to create some custom Dockerfiles to do what I described above in the near future. |
Related to issue #268 Signed-off-by: Musa Morena Marcusso Manhães <musa.marcusso@de.bosch.com>
Apparently one way to check (or debug) for the compatibility issue is to run the Python script file using co = compile(open(filename).read(), filename, 'exec') with Python 3. I will made the changes for the Python scripts (Python modules are next) in #357 |
That should catch the syntax changes, however there may be some sneaky runtime incompatibilities. FYI Looks like environment variables were added for python version osrf/docker_images#256 Edit: On further inspection that's ROS2 and not very useful. Nevermind. |
It looks like it is currently not possible to test with Python2 and 3 with ros-industrial/industrial_ci. The problem is that ROS1 has to be rebuild from scratch to support Python3. The ros-industrial guys are working to support this. Have a look at this PR: ros-industrial/industrial_ci#429 |
No description provided.
The text was updated successfully, but these errors were encountered: