Ask Your Question

Revision history [back]

As @William points out, it seems that the generate_distutils_setup included in the setup.py needs to know the location of the package.xml file. The call has an optional parameter that defaults to os.path.curdir which is usually ok since setup.py is included in the same dir as package.xml.

However, it seems that tox runs the setup.py in a virtual environment located in /tmp/. Therefore, if you don't tell generate_distutils_setup that you are running in a separate dir it will fail.

I've modified my setup.py to tell it where to find the real path of the package.xml file and now I can run my tox commands perfectly. That's how my setup.py looks like now:

#!/usr/bin/env python

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

import rospkg
THIS_PKG = 'rospy_utils'
rospack = rospkg.RosPack()
pkg_path = rospack.get_path(THIS_PKG)

d = generate_distutils_setup(
    # #  don't do this unless you want a globally visible script
    # scripts=['bin/myscript'],
    packages=['rospy_utils'],
    package_dir={'': 'src'},
    package_xml_path=pkg_path
)

adminstrosetup(**d)

EDIT:

I've found a cleaner way to solve it.

Ideally setup.py and package.xml should be in the same dir. However, this does not happens inside a tox venv unless you tell it what files should be included. To do so you need to create a MANIFEST.in in the same dir as setup.py and list there all the files you want to include in your source distribution. Here is what I put in my MANIFEST.in:

include package.xml

And my setup.py now is the barebones setup.py listed in the Catkin documentation:

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

d = generate_distutils_setup(
    # #  don't do this unless you want a globally visible script
    # scripts=['bin/myscript'],
    packages=['rospy_utils'],
    package_dir={'': 'src'}
)

adminstrosetup(**d)

It seems that every ROS-related file that you don't include in the MANIFEST.in won't be included in the source distribution that is put into the tox virtual env. I guess that, if you need to do some rostests, use some ROS msgs, etc., you might need to include them here as well.


Just for future reference, I leave the old answer here:

As @William points out, it seems that the generate_distutils_setup included in the setup.py needs to know the location of the package.xml file. The call has an optional parameter that defaults to os.path.curdir which is usually ok since setup.py is included in the same dir as package.xml.

However, it seems that tox runs the setup.py in a virtual environment located in /tmp/. Therefore, if you don't tell generate_distutils_setup that you are running in a separate dir it will fail.

I've modified my setup.py to tell it where to find the real path of the package.xml file and now I can run my tox commands perfectly. That's how my setup.py looks like now:

#!/usr/bin/env python

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

import rospkg
THIS_PKG = 'rospy_utils'
rospack = rospkg.RosPack()
pkg_path = rospack.get_path(THIS_PKG)

d = generate_distutils_setup(
    # #  don't do this unless you want a globally visible script
    # scripts=['bin/myscript'],
    packages=['rospy_utils'],
    package_dir={'': 'src'},
    package_xml_path=pkg_path
)

adminstrosetup(**d)

EDIT:

I've found a cleaner way to solve it.

Ideally setup.py and package.xml should be in the same dir. However, this does not happens inside a tox venv unless you tell it what files should be included. To do so you need to create a MANIFEST.in in the same dir as setup.py and list there all the files you want to include in your source distribution. Here is what I put in my MANIFEST.in:

include package.xml

And my setup.py now is the barebones setup.py listed in the Catkin documentation:

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

d = generate_distutils_setup(
    # #  don't do this unless you want a globally visible script
    # scripts=['bin/myscript'],
    packages=['rospy_utils'],
    package_dir={'': 'src'}
)

adminstrosetup(**d)

It seems that every ROS-related file that you don't include in the MANIFEST.in won't be included in the source distribution that is put into the tox virtual env. I guess that, if you need to do some rostests, use some ROS msgs, etc., you might need to include them here as well.


Just for future reference, I leave the old answer here:

As @William points out, it seems that the generate_distutils_setup included in the setup.py needs to know the location of the package.xml file. The call has an optional parameter that defaults to os.path.curdir which is usually ok since setup.py is included in the same dir as package.xml.

However, it seems that tox runs the setup.py in a virtual environment located in /tmp/. Therefore, if you don't tell generate_distutils_setup that you are running in a separate dir it will fail.

I've modified my setup.py to tell it where to find the real path of the package.xml file and now I can run my tox commands perfectly. That's how my setup.py looks like now:

#!/usr/bin/env python

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

import rospkg
THIS_PKG = 'rospy_utils'
rospack = rospkg.RosPack()
pkg_path = rospack.get_path(THIS_PKG)

d = generate_distutils_setup(
    # #  don't do this unless you want a globally visible script
    # scripts=['bin/myscript'],
    packages=['rospy_utils'],
    package_dir={'': 'src'},
    package_xml_path=pkg_path
)

adminstrosetup(**d)