Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 13 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import gc
import os
import platform
import pytest

from openpilot.common.prefix import OpenpilotPrefix
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions tools/mac_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 || :)"
Expand Down
4 changes: 4 additions & 0 deletions tools/sim/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down