colcon/colcon-core

Builds with ament_python broken with sphinx >= 7.0.0

oysstu opened this issue · 2 comments

The following way of obtaining a list of available commands from setup.py is broken on sphinx v7.0.0 and later.

async def _get_available_commands(self, path, env):
output = await check_output(
[executable, 'setup.py', '--help-commands'], cwd=path, env=env)
commands = set()
for line in output.splitlines():
if not line.startswith(b' '):
continue
try:
index = line.index(b' ', 2)
except ValueError:
continue
if index == 2:
continue
commands.add(
line[2:index].decode(locale.getpreferredencoding(False)))
return commands

This occurs because the setuptools integration is deprecated:
sphinx-doc/sphinx#9595 (comment)

The end result is that ament_python continues as normal, but installs the package as an egg without the egg-info.

if 'egg_info' in available_commands:

When building ros, the build will fail on ament_cmake_core because it cannot find ament_package. Egg modules are not imported even if the site-packages directory is in the python-path. It's possible to add something like this to make the egg import

import site
import os
site.addsitedir(os.path.split(__file__)[0])

However, there's further breakage later in the build process in cmake, as it expects template files in a certain location (and not inside the compressed egg).

Funnily enough, this actually seems to be a bug with Sphinx. I've filed a PR with them: sphinx-doc/sphinx#11418

Resolved in sphinx 7.0.1