Ask Your Question
0

Packaging error trying to run ROS tests from Tox

asked 2018-03-08 15:27:32 -0500

Cerin gravatar image

When I run tox to run Python tests in my ROS package, I'm getting the error:

ERROR: invocation failed (exit code 1), logfile: ros_qr_tracker/.tox/log/tox-0.log
ERROR: actionid: tox
msg: packaging
cmdargs: ['/usr/bin/python3', local('ros_qr_tracker/setup.py'), 'sdist', '--formats=zip', '--dist-dir', local('ros_qr_tracker/.tox/dist')]
env: None

Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    from catkin_pkg.python_setup import generate_distutils_setup
ImportError: No module named 'catkin_pkg'

ERROR: FAIL could not package project - v = InvocationError('/usr/bin/python3 ros_qr_tracker/setup.py sdist --formats=zip --dist-dir ros_qr_tracker/.tox/dist (see ros_qr_tracker/.tox/log/tox-0.log)', 1)

My package is for Python 2.7. Why is it trying to run with Python3?

My setup.py looks like:

#!/usr/bin/env python
import os

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))

def get_reqs(*fns):
    lst = []
    for fn in fns:
        for package in open(os.path.join(CURRENT_DIR, fn)).readlines():
            package = package.strip()
            if not package:
                continue
            lst.append(package.strip())
    return lst

d = generate_distutils_setup(
    version='0.1.0',
    packages=['ros_qr_tracker'],
    package_dir={'': 'src'},
    install_requires=get_reqs('pip-requirements.txt'),
)

setup(**d)

and my tox.ini looks like:

[tox]
envlist = py{27}
recreate = True

[testenv]
basepython =
    py27: python2.7
deps =
    -r{toxinidir}/pip-requirements.txt
    -r{toxinidir}/pip-requirements-test.txt
commands = nosetests -vv

As some other answers have pointed out, I've ensured catkin-pkg is installed by running sudo apt-get install python-catkin-pkg and dpkg -L python-catkin-pkg confirms the package was installed into Python2.7's site-packages, so the issue here seems to be that catkin-pkg is using the wrong version of Python. Why is this?

edit retag flag offensive close merge delete

Comments

so the issue here seems to be that catkin-pkg is using the wrong version of Python

catkin_pkg is a Python module, so a passive artefact. It cannot "use" a version of Python.

I would check to make sure that tox is using / targetting the right Python version.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-09 07:43:43 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-03-09 13:09:43 -0500

Cerin gravatar image

The problem was that I was using the version of tox in Ubuntu's standard repo package, which is a bit old. I uninstalled this and re-installed the latest from PyPI, and it correctly ran using Python2.7 instead of Python3.

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

1 follower

Stats

Asked: 2018-03-08 15:27:32 -0500

Seen: 122 times

Last updated: Mar 09 '18