ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Dependency on python module `sys`

asked 2021-12-01 09:43:43 -0500

CoffeeKangaroo gravatar image

updated 2021-12-02 03:22:50 -0500

I am working on a ROS noetic package which includes a node which imports the python sys module (in Ubuntu 20.04 with python3).

Is it necessary to declare the dependency on the sys module in the package.xml file?

  • If yes, which <exec_depend> is required? I had a look at the documentation on the documentation to python module dependencies, but I have not been able to find the <exec_depend> for sys in the rosditro repository.

  • If no, why is it not necessary to declare dependency on this import?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-12-01 10:17:54 -0500

gvdhoorn gravatar image

updated 2021-12-01 10:20:31 -0500

Is it necessary to declare the dependency on the sys module in the package.xml file?

No.

sys is a part of the Python standard library, which means it comes installed by-default whenever you install a version of the Python interpreter. Apart from that, you cannot "install" sys yourself as a stand-alone component or library for Python.

What you should exec_depend on would be rospy. This already depends on the correct version of Python.

Technically, your package should not depend on one of its dependencies to bring in one of its other direct dependencies (ie: if A depends on B and C, and B depends on C, A should not just depend on B, but also on C itself). But as rospy will almost certainly never drop its own dependency on Python, it would be safe to just depend on rospy.

edit flag offensive delete link more

Comments

1

Compare this to regular Python packaging: would you add a dependency on sys in your pyproject.toml and/or setup.py/setup.cfg? If the answer is "no", then you wouldn't need to add it to your ROS package.xml.

gvdhoorn gravatar image gvdhoorn  ( 2021-12-01 10:19:52 -0500 )edit

@gvdhoorn: Thanks for the detailed clarification.

So, can "would you add a dependency on xyz in your pyproject.toml?" be taken as a rule of thumb for dependencies on python packages which have to be defined in package.xml?

CoffeeKangaroo gravatar image CoffeeKangaroo  ( 2021-12-02 03:20:43 -0500 )edit
1

Any time you use something which is not part of the standard library it will have to be installed separately.

Anything that needs to be installed / present for your node to function should be expressed as a dependency.

gvdhoorn gravatar image gvdhoorn  ( 2021-12-02 03:28:24 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-12-01 09:43:43 -0500

Seen: 280 times

Last updated: Dec 02 '21