From f90655a1ff4a20e680d6f406b347462ca9cfd41a Mon Sep 17 00:00:00 2001 From: Mauricio Alvarez Leon <65101411+BBBmau@users.noreply.github.com> Date: Fri, 24 May 2024 21:38:23 -0700 Subject: [PATCH] `ubuntu_setup`: fix `No module apt_pkg` error when setting up (#32526) * no apt_pkg fix * check arch * fix if * cleanup * reorder * increase shm size for selfdrive tests * add comment explaining reinstall * refine old-commit-hash: f4322666c6adc4dd2da569f483f6e108f18fe32a --- .github/workflows/selfdrive_tests.yaml | 2 +- tools/install_python_dependencies.sh | 5 ++++- tools/install_ubuntu_dependencies.sh | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 1c83c39bbb..1aa08f205b 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -19,7 +19,7 @@ env: DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} BUILD: selfdrive/test/docker_build.sh base - RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e CI=1 -e PRE_COMMIT_HOME=/tmp/pre-commit -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/pre-commit:/tmp/pre-commit -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/bash -c + RUN: docker run --shm-size 1.5G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e CI=1 -e PRE_COMMIT_HOME=/tmp/pre-commit -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/pre-commit:/tmp/pre-commit -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/bash -c PYTEST: pytest --continue-on-collection-errors --cov --cov-report=xml --cov-append --durations=0 --durations-min=5 --hypothesis-seed 0 -n logical diff --git a/tools/install_python_dependencies.sh b/tools/install_python_dependencies.sh index 0a2ae0d580..eaa32a0a4b 100755 --- a/tools/install_python_dependencies.sh +++ b/tools/install_python_dependencies.sh @@ -15,7 +15,10 @@ export MAKEFLAGS="-j$(nproc)" echo "update pip" -if [ ! -z "\$VIRTUAL_ENV_ROOT" ] || [ ! -z "$INSTALL_DEADSNAKES_PPA" ] ; then +if [ ! -z "$VIRTUAL_ENV_ROOT" ] || [ ! -z "$INSTALL_DEADSNAKES_PPA" ] ; then + if [ -z "$VIRTUAL_ENV_ROOT" ]; then + export VIRTUAL_ENV_ROOT="venv" + fi python3 -m venv --system-site-packages $VIRTUAL_ENV_ROOT source $VIRTUAL_ENV_ROOT/bin/activate fi diff --git a/tools/install_ubuntu_dependencies.sh b/tools/install_ubuntu_dependencies.sh index cd3ba29342..2469168c74 100755 --- a/tools/install_ubuntu_dependencies.sh +++ b/tools/install_ubuntu_dependencies.sh @@ -113,11 +113,13 @@ function install_deadsnakes_ppa(){ echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then INSTALL_DEADSNAKES_PPA="yes" - export VIRTUAL_ENV_ROOT=".venv" fi fi if [[ "$INSTALL_DEADSNAKES_PPA" == "yes" ]]; then - $SUDO apt-get install software-properties-common -y --no-install-recommends + # The reinstall ensures that apt_pkg.cpython-35m-x86_64-linux-gnu.so exists + # by reinstalling python3-minimal since it's not present in /usr/lib/python3/dist-packages. + $SUDO apt install -y --no-install-recommends --reinstall python3-minimal + $SUDO apt-get install -y --no-install-recommends python3-apt software-properties-common $SUDO add-apt-repository ppa:deadsnakes/ppa $SUDO apt-get install -y --no-install-recommends \ python3.11-dev \