Skip to content

Commit

Permalink
mac: fix setup and re-enable CI (#23365)
Browse files Browse the repository at this point in the history
* rework mac_setup.sh
* ignore casadi and onnx runtime in pipfile for Darwin
* remove rust stuff
* build and install casadi

* add wget

* explicit python3. dont do onnx just yet

* resource compiler

* replace acados Darwin lib w universal2 libs

* relock Pipfile using linux machine

* Update update_requirements.sh

brackets

* Update update_requirements.sh

oops

* ci: re-enable mac build

* attempt to fix ci build:
* pip stuff?
* move rcc bin path to env script

* oops

* only mac

* k im lazy. does ci like this??

* huh??

* * use curl
* avoid casadi rebuilds
* add comment to remove protobuf
* host detect typo

* python version

* how did the builds not use swig?
* better reinstall check

* sometimes mac clang complain abt error limit

* ci: build OP in venv

* ci: bump to Big Sur
* retry? idk why it failed @ acados link

* * use macos-latest
* move rcc path to scons
* add extra paths for odd homebrew installs
* acados source change

* update macOS README

* uh, maybe?

* k nvm

* ci: ok this is strange. might be scons bug?

* fix conflicts: bump

* just add cppcheck for pre-commit stuff

* agane

* cleanup

* try that

* fix path

* no pyenv update on mac

* source

* fix rpath prefix?

* no examples

* fix exit

* let's get this cached

* add virtualenvs to cache

* why did we cache that

* let's see what's big

* more

* always ruyn

* cache scons cache

* better cache key

* fix for partial hit

* why so long

Co-authored-by: Andrew Tec <andrest@trabus.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Bruce Wayne <batman@openpilot-mac-mini.local>
  • Loading branch information
4 people committed Jan 7, 2022
1 parent 207ce41 commit 6664421
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 92 deletions.
102 changes: 56 additions & 46 deletions .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,52 +69,62 @@ jobs:
rm -rf /tmp/scons_cache/* && \
scons -j$(nproc) --cache-populate"
#build_mac:
# name: build macos
# runs-on: macos-10.15
# timeout-minutes: 60
# steps:
# - uses: actions/checkout@v2
# with:
# submodules: true
# - name: Determine pre-existing Homebrew packages
# if: steps.dependency-cache.outputs.cache-hit != 'true'
# run: |
# echo 'EXISTING_CELLAR<<EOF' >> $GITHUB_ENV
# ls -1 /usr/local/Cellar >> $GITHUB_ENV
# echo 'EOF' >> $GITHUB_ENV
# - name: Cache dependencies
# id: dependency-cache
# uses: actions/cache@v2
# with:
# path: |
# ~/.pyenv
# ~/Library/Caches/pip
# ~/Library/Caches/pipenv
# /usr/local/Cellar
# ~/github_brew_cache_entries.txt
# key: macos-cache-${{ hashFiles('tools/mac_setup.sh') }}
# - name: Brew link restored dependencies
# if: steps.dependency-cache.outputs.cache-hit == 'true'
# run: |
# while read pkg; do
# brew link --force "$pkg" # `--force` for keg-only packages
# done < ~/github_brew_cache_entries.txt
# - name: Install dependencies
# run: ./tools/mac_setup.sh
# - name: Build openpilot
# run: eval "$(pyenv init -)" && scons -j$(nproc)
# - name: Remove pre-existing Homebrew packages for caching
# if: steps.dependency-cache.outputs.cache-hit != 'true'
# run: |
# cd /usr/local/Cellar
# new_cellar=$(ls -1)
# comm -12 <(echo "$EXISTING_CELLAR") <(echo "$new_cellar") | while read pkg; do
# if [[ $pkg != "zstd" ]]; then # caching step needs zstd
# rm -rf "$pkg"
# fi
# done
# comm -13 <(echo "$EXISTING_CELLAR") <(echo "$new_cellar") | tee ~/github_brew_cache_entries.txt
build_mac:
name: build macos
runs-on: macos-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Determine pre-existing Homebrew packages
if: steps.dependency-cache.outputs.cache-hit != 'true'
run: |
echo 'EXISTING_CELLAR<<EOF' >> $GITHUB_ENV
ls -1 /usr/local/Cellar >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Cache dependencies
id: dependency-cache
uses: actions/cache@v2
with:
path: |
~/.pyenv
~/.local/share/virtualenvs/
/usr/local/Cellar
~/github_brew_cache_entries.txt
/tmp/scons_cache
key: macos-${{ hashFiles('tools/mac_setup.sh', 'update_requirements.sh', 'Pipfile*') }}
restore-keys: macos-
- name: Brew link restored dependencies
run: |
if [ -f ~/github_brew_cache_entries.txt ]; then
while read pkg; do
brew link --force "$pkg" # `--force` for keg-only packages
done < ~/github_brew_cache_entries.txt
else
echo "Cache entries not found"
fi
- name: Install dependencies
run: ./tools/mac_setup.sh
- name: Build openpilot
run: |
source tools/openpilot_env.sh
pipenv run selfdrive/manager/build.py
# cleanup scons cache
rm -rf /tmp/scons_cache/
pipenv run scons -j$(nproc) --cache-populate
- name: Remove pre-existing Homebrew packages for caching
if: steps.dependency-cache.outputs.cache-hit != 'true'
run: |
cd /usr/local/Cellar
new_cellar=$(ls -1)
comm -12 <(echo "$EXISTING_CELLAR") <(echo "$new_cellar") | while read pkg; do
if [[ $pkg != "zstd" ]]; then # caching step needs zstd
rm -rf "$pkg"
fi
done
comm -13 <(echo "$EXISTING_CELLAR") <(echo "$new_cellar") | tee ~/github_brew_cache_entries.txt
build_webcam:
name: build webcam
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tenacity = "*"

[packages]
atomicwrites = "*"
casadi = "*"
casadi = {version = "*", markers="platform_system != 'Darwin'"}
cffi = "*"
crcmod = "*"
cryptography = "*"
Expand All @@ -54,7 +54,7 @@ libusb1 = "*"
nose = "*"
numpy = "*"
onnx = "*"
onnxruntime-gpu = "*"
onnxruntime-gpu = {version = "*", markers="platform_system != 'Darwin'"}
pillow = "*"
psutil = "*"
pycapnp = "==1.1.0"
Expand Down
60 changes: 39 additions & 21 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ lenv = {
"LD_LIBRARY_PATH": [Dir(f"#third_party/acados/{arch}/lib").abspath],
"PYTHONPATH": Dir("#").abspath + ":" + Dir("#pyextra/").abspath,

"ACADOS_SOURCE_DIR": Dir("#third_party/acados/acados").abspath,
"ACADOS_SOURCE_DIR": Dir("#third_party/acados/include/acados").abspath,
"ACADOS_PYTHON_INTERFACE_PATH": Dir("#pyextra/acados_template").abspath,
"TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer",
}
Expand Down Expand Up @@ -125,15 +125,18 @@ else:
f"#third_party/libyuv/{yuv_dir}/lib",
"/usr/local/lib",
"/opt/homebrew/lib",
"/usr/local/Homebrew/Library",
"/usr/local/opt/openssl/lib",
"/opt/homebrew/opt/openssl/lib",
"/usr/local/Cellar",
f"#third_party/acados/{arch}/lib",
"/System/Library/Frameworks/OpenGL.framework/Libraries",
]
cflags += ["-DGL_SILENCE_DEPRECATION"]
cxxflags += ["-DGL_SILENCE_DEPRECATION"]
cpppath += [
"/opt/homebrew/include",
"/usr/local/include",
"/usr/local/opt/openssl/include",
"/opt/homebrew/opt/openssl/include"
]
Expand Down Expand Up @@ -235,6 +238,9 @@ env = Environment(
tools=["default", "cython", "compilation_db"],
)

if arch == "Darwin":
env['RPATHPREFIX'] = "-rpath "

if GetOption('compile_db'):
env.CompilationDatabase('compile_commands.json')

Expand Down Expand Up @@ -299,6 +305,7 @@ if arch == "Darwin":
qt_dirs += [f"{qt_env['QTDIR']}/include/Qt{m}" for m in qt_modules]
qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")]
qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"]
qt_env.AppendENVPath('PATH', os.path.join(qt_env['QTDIR'], "bin"))
elif arch == "aarch64":
qt_env['QTDIR'] = "/system/comma/usr"
qt_dirs = [
Expand Down
Binary file modified third_party/acados/Darwin/lib/libacados.dylib
Binary file not shown.
Binary file modified third_party/acados/Darwin/lib/libblasfeo.dylib
Binary file not shown.
Binary file modified third_party/acados/Darwin/lib/libhpipm.dylib
Binary file not shown.
Binary file modified third_party/acados/Darwin/lib/libqpOASES_e.3.1.dylib
Binary file not shown.
Loading

0 comments on commit 6664421

Please sign in to comment.