diff --git a/SConstruct b/SConstruct index 80273db106d03f..2e2f2d252226c4 100644 --- a/SConstruct +++ b/SConstruct @@ -117,6 +117,10 @@ elif arch == "Darwin": f"{brew_prefix}/include", f"{brew_prefix}/opt/openssl@3.0/include", ]) + # Ensure native Apple Silicon builds always target arm64 - issue with linker especially + env.Append(CCFLAGS=["-arch", "arm64"]) + env.Append(CXXFLAGS=["-arch", "arm64"]) + env.Append(LINKFLAGS=["-arch", "arm64"]) else: env.Append(LIBPATH=[ "/usr/lib", diff --git a/conftest.py b/conftest.py index 7e40ec3ed7a9d5..11c25792586619 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,7 @@ import contextlib import gc import os +import platform import pytest from openpilot.common.prefix import OpenpilotPrefix @@ -49,13 +50,20 @@ def clean_env(): def openpilot_function_fixture(request): with clean_env(): # setup a clean environment for each test - with OpenpilotPrefix(shared_download_cache=request.node.get_closest_marker("shared_download_cache") is not None) as prefix: - prefix = os.environ["OPENPILOT_PREFIX"] - + is_darwin = platform.system() == "Darwin" + if is_darwin: + # ZMQ backend is mandatory on macOS and forbids OPENPILOT_PREFIX + if "OPENPILOT_PREFIX" in os.environ: + del os.environ["OPENPILOT_PREFIX"] yield + else: + with OpenpilotPrefix(shared_download_cache=request.node.get_closest_marker("shared_download_cache") is not None) as prefix: + prefix = os.environ["OPENPILOT_PREFIX"] + + yield - # ensure the test doesn't change the prefix - assert "OPENPILOT_PREFIX" in os.environ and prefix == os.environ["OPENPILOT_PREFIX"] + # ensure the test doesn't change the prefix + assert "OPENPILOT_PREFIX" in os.environ and prefix == os.environ["OPENPILOT_PREFIX"] # cleanup any started processes manager.manager_cleanup() diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index 0ae0b35359e6e8..b3356a5da447f3 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -70,6 +70,18 @@ export PYCURL_SSL_LIBRARY=openssl $DIR/install_python_dependencies.sh echo "[ ] installed python dependencies t=$SECONDS" +# Ensure pip is available in the venv and rebuild PyAudio for ARM64 +VENV_PYTHON="$ROOT/.venv/bin/python" + +if ! "$VENV_PYTHON" -m pip --version &>/dev/null; then + echo "[ ] Bootstrapping pip in venv" + curl -sS https://bootstrap.pypa.io/get-pip.py | arch -arm64 "$VENV_PYTHON" +fi + +echo "[ ] Rebuilding PyAudio for ARM64" +arch -arm64 "$VENV_PYTHON" -m pip uninstall -y pyaudio || true +arch -arm64 "$VENV_PYTHON" -m pip install --no-binary :all: pyaudio + # brew does not link qt5 by default # check if qt5 can be linked, if not, prompt the user to link it QT_BIN_LOCATION="$(command -v lupdate || :)" diff --git a/tools/sim/tests/conftest.py b/tools/sim/tests/conftest.py index ddf66352767502..009cb52b778cd3 100644 --- a/tools/sim/tests/conftest.py +++ b/tools/sim/tests/conftest.py @@ -1,4 +1,8 @@ import pytest +import multiprocessing + +def pytest_configure(config): + multiprocessing.set_start_method("spawn", force=True) def pytest_addoption(parser): parser.addoption("--test_duration", action="store", default=60, type=int, help="Seconds to run metadrive drive")