bdaiinstitute/spatialmath-python

Installation Now Requires to Build An Old `matplotlib` Distribution

Closed this issue ยท 7 comments

Arnou1 commented

I have tried to install the latest spatialmath-python on macOS and Windows 11 through pip and building from source. However, none of my attempt was successful because they all failed to build matplotlib==3.5.1. When I specified the version of spatialmath to be 1.1.10, no error was raised and it also recognized and supported the newer matplotlib==3.9.0. This problem appears to persist from spatialmath-python 1.1.11 to 1.1.13. Below is the error message I got:

macOS

clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_backends__backend_agg_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -DFREETYPE_BUILD_TYPE=local -Ibuild/freetype-2.6.1/include -Iextern/agg24-svn/include -I/Users/name/Documents/Python/torch/lib/python3.12/site-packages/numpy/core/include -I/Users/name/Documents/Python/torch/include -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/_backend_agg.cpp -o build/temp.macosx-15.0-arm64-cpython-312/matplotlib.backends._backend_agg/src/_backend_agg.o -fvisibility=hidden -flto
In file included from src/_backend_agg.cpp:5:
src/_backend_agg.h:9:10: fatal error: 'cmath' file not found
9 | #include
| ^~~~~~~
1 error generated.
error: command '/usr/bin/clang++' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for matplotlib
Running setup.py clean for matplotlib
Failed to build matplotlib
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (matplotlib)

Windows

msbuild build\freetype-2.6.1\builds\windows\vc2010\freetype.sln /t:Clean;Build /p:Configuration=Release;Platform=x64
error: command 'msbuild' failed: None
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for matplotlib
Successfully built spatialmath-python
Failed to build matplotlib
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (matplotlib)

The Python packaging system and the relevant PEPs are very inflexible, there is no way for a user to specify an option at pip install time that will control which dependencies are in effect.

However, if you install the versions of the dependencies that you want then

pip install spatialmath-python --no-deps

will not mess with the version of any of the dependencies already installed.

spatialmath works fine with Numpy 2.2.1 and Matplotlib 3.10.0. Fine, as in the unit tests pass.

We added version pinning for matplotlib in the 1.1.11 release of spatialmath to help with version mismatch between apt-installed packages (in this case, matplotlib) and pip-installed spatialmath; the version mismatch was an issue on ROS2, using rosdep. I'm investigating how to relax the version pinning to avoid this issue, while continuing to avoid conflicts on ROS.

@jbarnett-bdai I understand the reason, but it frustrates me that ROS puts so many constraints on users. For now, perhaps we continue to ship the constrained version but publish the recipe (README, wiki) for those that want to cut loose. Superficially there are no issues with Numpy2 which I was surprised by, so kudos to the Numpy team.

I think the simplest solution here is to move the version pinning into an optional dependency, so that ROS users would do

pip install spatialmath[ros-humble]

I'll have a PR up shortly.

@Arnou1 I'm going to mark this as resolved.

Not sure if this can be considered completed as the issue seems to be still there -- see #150 (comment)