-
Notifications
You must be signed in to change notification settings - Fork 123
Add macOS ARM support for Thunderscope #3496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add macOS ARM support for Thunderscope #3496
Conversation
3ca31a1 to
c308ffb
Compare
environment_setup/util.sh
Outdated
| install_java_macos () { | ||
| java_home="" | ||
| java_download=https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz | ||
| curl -L $java_download -o /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| mkdir /tmp/tbots_download_cache/jdk | ||
| tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /tmp/tbots_download_cache | ||
| sudo mv /tmp/tbots_download_cache/jdk-21*/Contents/Home /opt/tbotspython/bin/jdk | ||
| rm /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| rm -rf /tmp/tbots_download_cache/jdk | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java Installed already from brew, I don't think we need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a specific version of Java for autoref (Java 21)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you're using the autoref binary package, so you can probably ignore this
itsarune
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments
environment_setup/util.sh
Outdated
| install_java_macos () { | ||
| java_home="" | ||
| java_download=https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz | ||
| curl -L $java_download -o /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| mkdir /tmp/tbots_download_cache/jdk | ||
| tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /tmp/tbots_download_cache | ||
| sudo mv /tmp/tbots_download_cache/jdk-21*/Contents/Home /opt/tbotspython/bin/jdk | ||
| rm /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| rm -rf /tmp/tbots_download_cache/jdk | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you're using the autoref binary package, so you can probably ignore this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should make sure you're using the same c++ compuler version as Ubuntu (to minimize the number of c++ compatibility changes that are needed)
| requirement("evdev"), | ||
| ], | ||
| ] + select({ | ||
| # TODO: remove this selection when we replace evdev to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tag an issue with the TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the target_compatible_with attribute?
https://bazel.build/reference/be/common-definitions#common.target_compatible_with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was the first thing we have tried, but it breaks the dependency tree because other targets depending one this are all marked incompatible. I will do more test on this.
c308ffb to
d6b303d
Compare
|
|
||
| import evdev | ||
| from evdev import ecodes | ||
| # TODO: remove the try-catch when we rewrite this with macOS-compatible lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need this with this change: https://github.com/UBC-Thunderbots/Software/pull/3496/files#r2551713285
src/.bazelrc
Outdated
| # Escalate Warnings to fail Compile for Thunderbots code | ||
| build --features=external_include_paths | ||
| build --per_file_copt=proto/.*,proto/message_translation/.*,proto/primitive/.*,software/.*,shared/.*,-external/.*@-Wall,-Wextra,-Wno-unused-parameter,-Wno-deprecated,-Werror,-Wno-deprecated-declarations | ||
| build:linux --features=external_include_paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally these flags would also work on macos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, ideally it should also work on macos, but because the macos clang compiler is stricter than linux and reports millions of new errors (converted from warnings). :(
itsarune
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
I think we are getting close w/ getting this working, I put in a PR last week to hopefully reconcile some bazel hermiticity issues and we'll run a test this week to check if it actually works on anyone else's machines aside from minghao's. |
|
Just a note, I did get this working on my m1 macbook as well. I did however have to resolve some c++ compatibility issues, and also update the package required for bazel refresh_compile_commands to resolve a bug. I'm not sure if these issues were also present on your macbook? We should definitely test some time with a clean install, and to test all scripts and commands that we want to support for mac to make sure they also work. |
|
@nycrat Personally, I dont use the refresh_compile_commands. That's a great catch. I think it is less likely to affect ubuntu users by just updating the version. I will cherry-pick your commit onto this. |
Interesting. Thanks for reminding me that. I intentionally did not run any of the unit tests, because I'd anticipate more failures than just 'feenableexcept' and 'fedisableexcept' (they have to be fixed by polyfilling, such as https://gitlab.dkrz.de/dkrz-sw/yac/-/blob/v3.9.1/src/core/feenableexcept.h). I definitely agree it will be great to have the unit tests running locally, but I wanted to scope this PR to just get Thunderscope UI running, so some of the UI visualization work can be running on mac. Currently, we have CI that checks the unit tests from each PR, so this should not be very urgent. I will work on unit tests in the upcoming PRs.
This is an another problem related to our network traffic in general (not just macos). This is more obvious on mac because there is a subtle difference between how macos and ubuntu implement the network interface. When the ubuntu system buffer is full, the system call will block. Whereas, on macos, it throws an error. |
nycrat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments mainly about the setup script
GrayHoang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will there be any issues with the new bazel_rules stuff again?
| @@ -0,0 +1,13 @@ | |||
| ansible-lint==24.12.2 | |||
| pyqtgraph==0.13.7 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these can be removed pending #3542 I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do a merge test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh I think bazel has no problem with your PR, everything compiles. But PyQt6 conflicts still exist with the current commit 9fce33a1727218c76ee0e1b37ee26bbbd1d0a1e1. I would guess this issue is normal because you have not resolved this PyQt lib conflict in your branch yet?
Full Error message:
INFO: Running command line: bazel-bin/software/thunderscope/thunderscope_main
⚠ Conflicting symlinks found when attempting to create venv. More than one package provides the file at these paths
╭─[1:208]
1 │ /private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/PyQt6/__init__.py
· ───────────────┬───────────────
· ╰── Existing file in virtual environment
2 │ /private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/rules_python++pip+thunderscope_deps_312_pyqt6/site-packages/PyQt6/__init__.py
· ───────────────┬───────────────
· ╰── Next file to link
╰────
help: Set `package_collisions = "ignore"` on the binary or test rule to ignore this warning
Traceback (most recent call last):
File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/_main/software/thunderscope/thunderscope_main.py", line 18, in <module>
from software.thunderscope.thunderscope import Thunderscope
File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/_main/software/thunderscope/thunderscope.py", line 7, in <module>
import pyqtgraph
File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/__init__.py", line 18, in <module>
from .colors import palette
File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/colors/palette.py", line 1, in <module>
from ..Qt import QtGui
File "/private/var/tmp/_bazel_liminghao/32d7fe8baee71625f01e1bffab4e0a4a/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/software/thunderscope/thunderscope_main.runfiles/.thunderscope_main.venv/lib/python3.12/site-packages/pyqtgraph/Qt/__init__.py", line 57, in <module>
raise ImportError("PyQtGraph requires one of PyQt5, PyQt6, PySide2 or PySide6; none of these packages could be imported.")
ImportError: PyQtGraph requires one of PyQt5, PyQt6, PySide2 or PySide6; none of these packages could be imported.
|
not working :( /opt/tbotspython/lib/python3.12/site-packages/iterfzf/init.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging |
|
Adding |
Andrewyx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
sauravbanna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome !
| } | ||
|
|
||
| is_darwin() { | ||
| if [[ $1 == "Darwin" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor nit: add a comment here similar to line 15 in environment_setup/setup_software_mac.sh to explain what Darwin is



closes #3529
Description
This PR introduces native macOS ARM support for Thunderscope.
Currently, this PR is experimental and is just providing a minimal working demo on my macbook M1.
Out of scope for this PR:
Testing Done
TODO List
For this PR:
local_new_repositoriesand confirm compatibility with Ubuntuevdevdoes not exist for macos.Maybe for future PRs or possibly this PR:
TbotsProto.ObstacleListto prevent system network buffer overload (TrajectoryPlanner improvements #3104). This is impacting the stability of thunderscope on macOS. I am currently working on a sliding window cache that hopefully can mitigate this issue.