From: Sun Yuechi Date: Sat, 6 Jun 2026 18:05:34 +0000 (+0800) Subject: test: optionally run test venvs with system site-packages X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ae6bc8220b7b7a229d32064ea5dc2f3d88badbae;p=ceph.git test: optionally run test venvs with system site-packages Add a CEPH_PYTHON_SYSTEM_SITE switch (off by default). When set: - setup-virtualenv.sh builds its venv with --system-site-packages; - run_tox.sh exports VIRTUALENV_SYSTEM_SITE_PACKAGES=true for tox's venvs. This lets distro packages satisfy test dependencies instead of pip building them from sdist, which helps where prebuilt wheels are missing (e.g. scipy and numpy on riscv64) by avoiding a slow rebuild when the RPMs are installed. Signed-off-by: Sun Yuechi --- diff --git a/src/script/run_tox.sh b/src/script/run_tox.sh index f2f71a60f29..61fdea28ccf 100755 --- a/src/script/run_tox.sh +++ b/src/script/run_tox.sh @@ -125,6 +125,10 @@ function main() { export CEPH_BUILD_DIR=$build_dir # use the wheelhouse prepared by install-deps.sh export PIP_FIND_LINKS="$tox_path/wheelhouse" + # CEPH_PYTHON_SYSTEM_SITE (default off): let tox's venvs see system site-packages + if ${CEPH_PYTHON_SYSTEM_SITE:-false}; then + export VIRTUALENV_SYSTEM_SITE_PACKAGES=true + fi tox_cmd=(tox -c $tox_path/tox.ini) if [ "$tox_envs" != "__tox_defaults__" ]; then tox_cmd+=("-e" "$tox_envs") diff --git a/src/tools/setup-virtualenv.sh b/src/tools/setup-virtualenv.sh index 152e4859715..5dba693c26e 100755 --- a/src/tools/setup-virtualenv.sh +++ b/src/tools/setup-virtualenv.sh @@ -62,7 +62,12 @@ if [ -z "$DIR" ] ; then fi rm -fr $DIR mkdir -p $DIR -$PYTHON -m venv $DIR +# CEPH_PYTHON_SYSTEM_SITE (default off): build venv against system site-packages +VENV_OPTS= +if ${CEPH_PYTHON_SYSTEM_SITE:-false}; then + VENV_OPTS="--system-site-packages" +fi +$PYTHON -m venv $VENV_OPTS $DIR . $DIR/bin/activate if pip --help | grep -q disable-pip-version-check; then