Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
650964d
rework mac_setup.sh
tecandrew Jan 3, 2022
3ac7bc3
add wget
tecandrew Jan 3, 2022
062f2c3
explicit python3. dont do onnx just yet
tecandrew Jan 3, 2022
2ab607b
resource compiler
tecandrew Jan 3, 2022
bdc990e
replace acados Darwin lib w universal2 libs
tecandrew Jan 3, 2022
6081c2e
relock Pipfile using linux machine
tecandrew Jan 3, 2022
05242f8
Update update_requirements.sh
tecandrew Jan 3, 2022
4eabc9f
Update update_requirements.sh
tecandrew Jan 3, 2022
e2fe689
ci: re-enable mac build
tecandrew Jan 3, 2022
018f78a
attempt to fix ci build:
tecandrew Jan 3, 2022
5a94b5c
oops
tecandrew Jan 3, 2022
ea714aa
only mac
tecandrew Jan 3, 2022
50415af
k im lazy. does ci like this??
tecandrew Jan 3, 2022
9088881
Merge branch 'fix-apple' of github.com:tecandrew/openpilot into fix-a…
tecandrew Jan 3, 2022
775b880
huh??
tecandrew Jan 3, 2022
e45c6c8
* use curl
tecandrew Jan 5, 2022
7c762b4
python version
tecandrew Jan 5, 2022
1f9c430
how did the builds not use swig?
tecandrew Jan 5, 2022
c83159c
sometimes mac clang complain abt error limit
tecandrew Jan 5, 2022
6bbd27a
ci: build OP in venv
tecandrew Jan 5, 2022
da81c2a
ci: bump to Big Sur
tecandrew Jan 5, 2022
cf6310e
* use macos-latest
tecandrew Jan 5, 2022
2d1bff7
update macOS README
tecandrew Jan 5, 2022
f614e75
uh, maybe?
tecandrew Jan 5, 2022
642ce6d
k nvm
tecandrew Jan 5, 2022
69a4d27
ci: ok this is strange. might be scons bug?
tecandrew Jan 5, 2022
e6cefbe
fix conflicts: bump
tecandrew Jan 5, 2022
832ca11
just add cppcheck for pre-commit stuff
tecandrew Jan 5, 2022
9d8cec0
agane
tecandrew Jan 5, 2022
f15c2da
Merge branch 'master' into fix-apple
tecandrew Jan 5, 2022
16c225f
cleanup
adeebshihadeh Jan 5, 2022
c5f3702
try that
Jan 5, 2022
eac9f66
fix path
Jan 5, 2022
256e19f
no pyenv update on mac
Jan 5, 2022
a0784b8
source
Jan 5, 2022
d87feb5
fix rpath prefix?
Jan 6, 2022
fafb2e2
no examples
Jan 6, 2022
ad70579
fix exit
Jan 6, 2022
aa47df4
let's get this cached
Jan 6, 2022
ce8a276
add virtualenvs to cache
Jan 6, 2022
07568a5
why did we cache that
Jan 6, 2022
0f0c27c
let's see what's big
Jan 6, 2022
4ac0a93
more
Jan 6, 2022
83ebd1e
always ruyn
Jan 6, 2022
e0b6dfd
cache scons cache
Jan 6, 2022
f9e8294
better cache key
Jan 7, 2022
12c650b
fix for partial hit
Jan 7, 2022
cdd8ee2
why so long
Jan 7, 2022
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
92 changes: 46 additions & 46 deletions .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,52 +69,52 @@ 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-11
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: pipenv run 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_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 @@ -35,7 +35,7 @@ tenacity = "*"

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

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

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.
43 changes: 31 additions & 12 deletions tools/mac_setup.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/bin/bash -e

PYTHON_VERSION=3.8.10
PYTHON_VER=3.8
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
ROOT="$(cd $DIR/../ && pwd)"
ARCH=$(uname -m)

# Install brew if required
if [[ $(command -v brew) == "" ]]; then
echo "Installing Hombrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi

## TODO remove protobuf,protobuf-c,swig when
## casadi pip package is available
brew bundle --file=- <<-EOS
brew "cmake"
brew "git-lfs"
brew "zlib"
brew "bzip2"
brew "rust"
brew "rustup-init"
brew "capnp"
brew "coreutils"
brew "eigen"
Expand All @@ -29,6 +31,9 @@ brew "openssl"
brew "pyenv"
brew "qt@5"
brew "zeromq"
brew "protobuf"
brew "protobuf-c"
brew "swig"
cask "gcc-arm-embedded"
EOS

Expand All @@ -38,12 +43,6 @@ elif [[ $SHELL == "/bin/bash" ]]; then
RC_FILE="$HOME/.bash_profile"
fi

# TODO: get rid of this somehow
# Build requirements for macOS
# https://github.com/pyenv/pyenv/issues/1740
# https://github.com/pyca/cryptography/blob/main/docs/installation.rst
rustup-init -y

export LDFLAGS="$LDFLAGS -L/usr/local/opt/zlib/lib"
export LDFLAGS="$LDFLAGS -L/usr/local/opt/bzip2/lib"
export LDFLAGS="$LDFLAGS -L/usr/local/opt/[email protected]/lib"
Expand All @@ -55,15 +54,35 @@ export PATH="$PATH:/usr/local/bin"

# openpilot environment
if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then
echo "export PATH=\"\$PATH:$HOME/.cargo/bin\"" >> $RC_FILE
echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE
export PATH="$PATH:\"\$HOME/.cargo/bin\""
source "$ROOT/tools/openpilot_env.sh"
echo "Added openpilot_env to RC file: $RC_FILE"
fi

# install python dependencies
$ROOT/update_requirements.sh
$ROOT/update_requirements.sh || true

# install casadi
VENV=`pipenv --venv`
if [ ! -f "$VENV/include/casadi/casadi.hpp" ]; then
echo "-- casadi manual install"
cd /tmp/ && curl -L https://github.com/casadi/casadi/archive/refs/tags/ge6.tar.gz --output casadi.tar.gz
tar -xzf casadi.tar.gz
cd casadi-ge6/ && mkdir -p build && cd build
cmake .. \
-DWITH_PYTHON=ON \
-DCMAKE_INSTALL_PREFIX:PATH=$VENV \
-DPYTHON_PREFIX:PATH=$VENV/lib/python$PYTHON_VER/site-packages \
-DPYTHON_LIBRARY:FILEPATH=$HOME/.pyenv/versions/$PYTHON_VERSION/lib/libpython$PYTHON_VER.dylib \
-DPYTHON_EXECUTABLE:FILEPATH=$HOME/.pyenv/versions/$PYTHON_VERSION/bin/python \
-DPYTHON_INCLUDE_DIR:PATH=$HOME/.pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_VER \
-DCMAKE_CXX_FLAGS="-ferror-limit=0" -DCMAKE_C_FLAGS="-ferror-limit=0"
CFLAGS="-ferror-limit=0" make -j$(nproc) && make install
else
echo "---- 'casadi found in venv. skipping build ----"
fi

cd $ROOT

echo
echo "---- FINISH OPENPILOT SETUP ----"
Expand Down
12 changes: 12 additions & 0 deletions tools/openpilot_env.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
if [ -z "$OPENPILOT_ENV" ]; then
OP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
ARCH="$(uname -m)"
HOST="$(uname -s)"

export PYTHONPATH="$OP_ROOT:$PYTHONPATH"
export PATH="$HOME/.pyenv/bin:$PATH"

# for qt resource compiler "rcc"
if [[ "$HOST" == "Darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"
else # x86_64 intel
export PATH="/opt/local/opt/qt@5/bin:$PATH"
fi
fi

# Pyenv suggests we place the below two lines in .profile before we source
# .bashrc, but there is no simple way to guarantee we do this correctly
# programmatically across heterogeneous systems. For end-user convenience,
Expand Down
35 changes: 25 additions & 10 deletions update_requirements.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e

HOST="$(uname -s)"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd $DIR

Expand All @@ -17,14 +17,25 @@ if ! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null; then
CONFIGURE_OPTS="--enable-shared" pyenv install -f ${PYENV_PYTHON_VERSION}
fi

if ! command -v pipenv &> /dev/null; then
echo "pipenv install ..."
pip install pipenv
fi
if [[ "$HOST" != "Darwin" ]]; then
if ! command -v pipenv &> /dev/null; then
echo "pipenv install ..."
pip install pipenv
fi

echo "update pip"
pip install pip==21.3.1
pip install pipenv==2021.11.23
else # MacOS
if ! command -v pipenv &> /dev/null; then
echo "pipenv install ..."
python3 -m pip install pipenv
fi

echo "update pip"
pip install pip==21.3.1
pip install pipenv==2021.11.23
echo "update pip"
python3 -m pip install pip==21.3.1
python3 -m pip install pipenv==2021.11.23
fi

if [ -d "./xx" ]; then
export PIPENV_SYSTEM=1
Expand All @@ -37,8 +48,12 @@ else
RUN=""
fi

echo "pip packages install ..."
pipenv install --dev --deploy --clear
echo "pip packages install for $HOST ..."
if [[ "$HOST" == "Darwin" ]]; then
pipenv install --dev --deploy --clear --skip-lock
else
pipenv install --dev --deploy --clear
fi
pyenv rehash

if [ -f "$DIR/.pre-commit-config.yaml" ]; then
Expand Down