Fix plugin-sanity-check venv collision with PEP 832 .venv redirect
virtualenv >= 21.12.0 implements the provisional PEP 832 feature that, when an environment is created, drops a ".venv" redirect file in the nearest parent directory holding a pyproject.toml (and without a .venv yet). The tempest repository root holds a pyproject.toml, so when tox builds the plugin-sanity-check environment a ".venv" text file is written there, pointing at ".tox/plugin-sanity-check". prepare_workspace() in tools/tempest-plugin-sanity.sh then runs "python3 -m venv .venv" without removing a pre-existing .venv. Python's stdlib venv refuses to create an environment over an existing non-directory and fails with "Unable to create directory", breaking the job on the first plugin. This has been failing every change since 2026-09-24 (virtualenv 21.12.0 release) and still reproduces with virtualenv 21.14.5. Create the sanity virtualenv in a ".virtualenv" directory instead, so it no longer collides with the PEP 832 redirect, and point with_venv.sh (used only by this script) at it. The redirect file is left untouched. The new directory is also added to the .gitignore and flake8 exclude lists. Closes-Bug: #2169582 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Change-Id: I9082a7c366ec4986f586fc7cf21371bcf98c53f0 Signed-off-by: Eduardo Olivares <eolivare@redhat.com>
This commit is contained in:
1 parent
5692e968f9
commit
911dc91ed4
4 files changed
+10
-3
No files matched your search
@@ -20,6 +20,7 @@ include/swift_objects/swift_large
|
||||
*.egg*
|
||||
.tox
|
||||
.venv
|
||||
.virtualenv
|
||||
dist
|
||||
build
|
||||
.testrepository
|
||||
|
||||
@@ -66,7 +66,13 @@ DEPS="-c${TOX_CONSTRAINTS_FILE}"
|
||||
# function to create virtualenv to perform sanity operation
|
||||
function prepare_workspace {
|
||||
SANITY_DIR=$(pwd)
|
||||
python3 -m venv "$SANITY_DIR"/.venv
|
||||
# NOTE: Use .virtualenv instead of .venv. Recent virtualenv versions
|
||||
# (>=21.12.0) drop a PEP 832 ".venv" redirect file in any directory that
|
||||
# holds a pyproject.toml (the tempest repo root does) when tox builds this
|
||||
# environment. That file would collide with "python3 -m venv .venv", which
|
||||
# fails to create a venv on top of an existing non-directory. Using a
|
||||
# different directory avoids the clash and leaves the redirect alone.
|
||||
python3 -m venv "$SANITY_DIR"/.virtualenv
|
||||
export TVENV="$SANITY_DIR/tools/with_venv.sh"
|
||||
cd "$SANITY_DIR"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
TOOLS_PATH=${TOOLS_PATH:-$(dirname $0)/../}
|
||||
VENV_PATH=${VENV_PATH:-${TOOLS_PATH}}
|
||||
VENV_DIR=${VENV_DIR:-/.venv}
|
||||
VENV_DIR=${VENV_DIR:-/.virtualenv}
|
||||
VENV=${VENV:-${VENV_PATH}/${VENV_DIR}}
|
||||
source ${VENV}/bin/activate && "$@"
|
||||
@@ -401,7 +401,7 @@ import_exceptions = tempest.services
|
||||
# I201 and I202 skipped because the rule does not allow new line between 3rd party modules and own modules
|
||||
ignore = E125,E123,E129,W504,H405,I201,I202,T117
|
||||
show-source = True
|
||||
exclude = .git,.venv,.tox,dist,doc,*egg,build
|
||||
exclude = .git,.venv,.virtualenv,.tox,dist,doc,*egg,build
|
||||
enable-extensions = H106,H203,H904
|
||||
import-order-style = pep8
|
||||
|
||||
|
||||
Reference in new issue
Block a user