Help Needed: Build Error with stretch_funmap Due to Numpy Dependency

Hi everyone,

I’m encountering a build error while setting up the Hello Robot workspace. Here’s what I did:

  1. Cloned the repository:
cd ~
git clone https://github.com/hello-robot/stretch_install
cd stretch_install
git pull
  1. Ran the update script:
./stretch_update_ros_workspace.sh

During the process of installing stretch_web_interface’s dependencies, numpy==1.24.4 gets installed, which leads to the following error:

  from numpy.distutils.mingw32ccompiler import generate_manifest
  File "/home/hello-robot/.local/lib/python3.10/site-packages/numpy/distutils/mingw32ccompiler.py", line 28, in <module>
    from distutils.msvccompiler import get_build_version as get_build_msvc_version
ModuleNotFoundError: No module named 'distutils.msvccompiler'
---
Failed   <<< stretch_funmap [29.1s, exited with code 1]

Issue Details:

It seems that the problem stems from numpy==1.24.4, which introduces some dependency issues with distutils.msvccompiler.

However, when I upgrade numpy==2.1.4, the build error disappeared.

Has anyone else faced a similar issue?

Thanks in advance for your help!

Hi @allen, the fix for this build issue was merged on Friday. Details on the fix here. To resolve the issue, you can first follow the instructions here to get uv, and then follow the normal instructions to update your ROS workspace. This should resolve the build issue you’re seeing.

1 Like

Hi @bshah , thanks for getting back to me on this issue. However, after installing uv, and follow the normal instructions to update my ROS workspace, it still failed to complete the update.

Here’s the breakdown of the issue: I’m running into an issue while following the workspace update instructions for Stretch ROS2. The problem occurs when executing the script:

./stretch_install/factory/22.04/stretch_create_ament_workspace.sh

Specifically, the error happens at this line:

uv run cythonize stretch_funmap/cython_min_cost_path.pyx -3 -i

Error Description

When the script reaches the Cythonization step, I get the following error:

error: Multiple top-level packages discovered in a flat-layout: ['rviz', 'launch', 'images', 'resource', 'tmpte6sgat5', 'stretch_funmap'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.

Steps to Reproduce

Follow the workspace update instructions for Stretch ROS2.

Additional Context

I was able to dig in and found out the issue is happening in pyproject.toml file. There’s seems to be conflicts between pyproject.toml and setup.py within stretch_funmap package.

Thanks in advance for your help! I really appreciate it!

Hey @allen, thanks for the details regarding this error. I’m not able to reproduce it, so let’s take it step-by-step and see if we can uncover more details.

Can you run each step below, one at a time, and collect the output (any errors) of each step:

rm -rf ~/ament_ws
mkdir -p ~/ament_ws/src
cd ~/ament_ws/src
vcs import --input ~/stretch_install/factory/22.04/stretch_ros2_humble.repos
cd ~/ament_ws/src/stretch_ros2/stretch_funmap
uv venv --system-site-packages --allow-existing .venv
uv sync --frozen
uv run cythonize stretch_funmap/cython_min_cost_path.pyx -3 -i
cd ~/ament_ws
colcon build --symlink-install
1 Like

Sure @bshah , here’s the output from each step.

Environment: SE3, Ubuntu 22.04


Command

rm -rf ~/ament_ws
mkdir -p ~/ament_ws/src
cd ~/ament_ws/src
vcs import --input ~/stretch_install/factory/22.04/stretch_ros2_humble.repos

Output (No errors):

=== ./audio_common (git) ===
Cloning into '.'...
=== ./realsense-ros (git) ===
Cloning into '.'...
Note: switching to '4.55.1'.
...
HEAD is now at 8a86cb88 4.55.1
=== ./sllidar_ros2 (git) ===
Cloning into '.'...
Note: switching to '34300099fadfc772965962dec837bf436706188f'.
...
HEAD is now at 3430009 bugfix:set the minimum distance to 5cm
...

Command

cd ~/ament_ws/src/stretch_ros2/stretch_funmap
uv venv --system-site-packages --allow-existing .venv

Output (No errors):

Using CPython 3.10.12 interpreter at: /usr/bin/python3.10
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate

uv sync --frozen

Output (No error):

Installed 25 packages in 29ms
 + cma==4.0.0
 + contourpy==1.3.1
 + cycler==0.12.1
 + ...
 + transforms3d==0.4.2

Command

uv run cythonize stretch_funmap/cython_min_cost_path.pyx -3 -i

Output (Error):

Compiling /home/hello-robot/ament_ws/src/stretch_ros2/stretch_funmap/stretch_funmap/cython_min_cost_path.pyx because it changed.
[1/1] Cythonizing /home/hello-robot/ament_ws/src/stretch_ros2/stretch_funmap/stretch_funmap/cython_min_cost_path.pyx
error: Multiple top-level packages discovered in a flat-layout: ['rviz', 'launch', 'images', 'resource', 'tmpugwgwciy', 'stretch_funmap'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.

Fails due to multiple top-level packages being detected.


Command

cd ~/ament_ws
colcon build --symlink-install

Output (Build Error):

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 268, in run_setup
    exec(code, g)
  File "<string>", line 6, in <module>
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 160, in setup
    dist.parse_config_files()
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/dist.py", line 652, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 73, in apply_configuration
    return _apply(dist, config, filepath)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 54, in apply
    _apply_project_table(dist, config, root_dir)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 81, in _apply_project_table
    corresp(dist, value, root_dir)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 193, in _license
    _set_config(dist, "license", _static.Str(val["text"]))
KeyError: 'text'
--- stderr: stretch_funmap                   
Traceback (most recent call last):
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_ros/task/ament_python/build.py", line 51, in build
    setup_py_data = get_setup_data(self.context.pkg, env)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
    return dict(pkg.metadata[key](env))
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_ros/package_augmentation/ros_ament_python.py", line 57, in getter
    return get_setup_information(
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 249, in get_setup_information
    _setup_information_cache[hashable_env] = _get_setup_information(
  File "/home/hello-robot/.local/lib/python3.10/site-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 296, in _get_setup_information
    result = subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError):    from setuptools.extern.packaging.specifiers    import SpecifierSet");exec("with suppress(ImportError):    from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup(    \'setup.py\', script_args=(\'--dry-run\',), stop_after=\'config\');skip_keys = (\'cmdclass\', \'distclass\', \'ext_modules\', \'metadata\');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith(\'_\') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data[\'metadata\'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in (\'license_files\', \'provides_extras\')};sys.stdout.buffer.write(repr(data).encode(\'utf-8\'))']' returned non-zero exit status 1.
---
Failed   <<< stretch_funmap [0.20s, exited with code 1]

Summary: 0 packages finished [0.34s]
  1 package failed: stretch_funmap
  1 package had stderr output: stretch_funmap
Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError):    from setuptools.extern.packaging.specifiers    import SpecifierSet");exec("with suppress(ImportError):    from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup(    \'setup.py\', script_args=(\'--dry-run\',), stop_after=\'config\');skip_keys = (\'cmdclass\', \'distclass\', \'ext_modules\', \'metadata\');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith(\'_\') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data[\'metadata\'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in (\'license_files\', \'provides_extras\')};sys.stdout.buffer.write(repr(data).encode(\'utf-8\'))']' returned non-zero exit status 1.


Summary of Issues:

  1. Cython Compilation Failure: Multiple top-level packages detected.
  2. Build Failure in stretch_funmap:
    • setup.py metadata issues (license, authors, scripts outside pyproject.toml).

Approaches I Tried

  • Reinstalling UV
  • Edit pyproject.toml based on reference here
  • Upgrade pip and setup tools

Thanks again in advance for your help!

Update

I was able to resolved the cythonize and build error by uninstalling setuptools & numpy: pip uninstall setuptools numpy, and downgrading em: pip install 'empy<4.0' to the system default version. Turns out the python package comflicts is the main reason the error persists and also the reason that you are not able to reproduce the error.
After testing both cythonize step and stretch_funmap is build successfully, I was able to run the update ros2 workspace code without any failures, thanks again for your help!

Thanks @allen, I’ve just pushed some fixes. Go ahead and try updating the ROS workspace again.

2 Likes

The update worked now, thanks!!

2 Likes