Closed lalten closed 6 months ago
So 2 years ago, in #687, I switched
ros2doctor
from usingpython3-ifcfg
to usingpython3-psutil
for network configuration. If it is possible, I think we should prefer to switch to usingpython3-psutil
here to reduce our dependencies. @lalten can you take a look at thepython3-psutil
APIs and see if we can accomplish the same thing?
Oh very cool, I had no idea psutil could do network things. I will give it a try. If that works out we also don't need https://github.com/ros/rosdistro/pull/39511
I changed to psutil, it works great and is very compatible to previous behavior. Would be happy about a review @clalancette :)
@lalten thanks for the contribution.
Is it possible to land this in the next Humble patch release as well?
I'd like to keep this in Rolling for a while before we do that, to see if any problems come up.
Even so, I actually don't see a compelling reason to do it. netifaces
is available in Ubuntu 22.04 (where Humble is supported), and will remain so for the lifetime of the distribution. So I guess I just don't see the need to make this lateral move and risk regressions.
netifaces is unmaintained: https://github.com/al45tair/netifaces/issues/78. It does not provide official prebuilt wheels for Python > 3.9: https://pypi.org/project/netifaces/#files
https://pypi.org/project/psutil/ is an alternative (available in rosdep as
python3-psutil
) but the interface is a little different.The reason I'm making this change is that we want to upgrade to a Python>3.9 but not provide a compiler inside our CI container (Unrelated to this PR, but we're using Bazel with a standalone hermetic compiler toolchain and https://github.com/mvukov/rules_ros2). Not having a host compiler for Python wheel builds makes it more difficult to build netifaces.
There are only two
netifaces
usages in ros2cli:LocalXMLRPCServer It just needs a list of available IPv4s (only
AF_INET
, noAF_INET6
). ifaddr can provide a one-line replacement for theget_local_ipaddrs()
function:NetworkAwareNode It must restart if network interfaces change. Currently it's checking for changes by comparing a (default)dict containing netiface's data. In my ifaddr replacement it will instead compare a set of repr-strings that contain all data ifaddr provides.
Note that I haven't tested this, but this should work fine on Windows as well.