From b1870f1c8456fdbf224bf43a9ee70521aa653689 Mon Sep 17 00:00:00 2001 From: Ankita Victor Date: Tue, 7 Jan 2025 11:13:10 -0800 Subject: [PATCH] build: Install packages and modules for format (#11649) Summary: Install regex, cmake-format and clang-format. make format-fix on a fresh Ubuntu installation returns ``` scripts/check.py format main --fix Traceback (most recent call last): File "/home/av/src/Velox/scripts/check.py", line 20, in import regex ModuleNotFoundError: No module named 'regex' make: *** [Makefile:172: format-fix] Error 1 /bin/sh: 1: cmake-format: not found error: cannot find executable "clang-format" ``` Pull Request resolved: https://github.com/facebookincubator/velox/pull/11649 Reviewed By: kKPulla Differential Revision: D67881970 Pulled By: kevinwilfong fbshipit-source-id: ff061733efb7ba048adcf6a394969743f4d9ae81 --- scripts/setup-ubuntu.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/setup-ubuntu.sh b/scripts/setup-ubuntu.sh index 7576fde00f16..537fc7a0325c 100755 --- a/scripts/setup-ubuntu.sh +++ b/scripts/setup-ubuntu.sh @@ -43,6 +43,7 @@ USE_CLANG="${USE_CLANG:-false}" export INSTALL_PREFIX=${INSTALL_PREFIX:-"/usr/local"} DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download} VERSION=$(cat /etc/os-release | grep VERSION_ID) +PYTHON_VENV=${PYTHON_VENV:-"${SCRIPTDIR}/../.venv"} # On Ubuntu 20.04 dependencies need to be built using gcc11. # On Ubuntu 22.04 gcc11 is already the system gcc installed. @@ -94,7 +95,12 @@ function install_build_prerequisites { git \ pkg-config \ wget - + + if [ ! -f ${PYTHON_VENV}/pyvenv.cfg ]; then + echo "Creating Python Virtual Environment at ${PYTHON_VENV}" + python3 -m venv ${PYTHON_VENV} + fi + source ${PYTHON_VENV}/bin/activate; # Install to /usr/local to make it available to all users. ${SUDO} pip3 install cmake==3.28.3 @@ -106,6 +112,14 @@ function install_build_prerequisites { } +# Install packages required to fix format +function install_format_prerequisites { + pip3 install regex + ${SUDO} apt install -y \ + clang-format \ + cmake-format +} + # Install packages required for build. function install_velox_deps_from_apt { ${SUDO} apt update @@ -287,6 +301,7 @@ function install_velox_deps { function install_apt_deps { install_build_prerequisites + install_format_prerequisites install_velox_deps_from_apt }