Skip to content

Commit 6bff8fd

Browse files
committed
Install virtual environment in current directory instead of /tmp
This solves the issue of pytest 8.0.0 not being able to run tests from /tmp/ directory. See pytest-dev/pytest#11807
1 parent 904f989 commit 6bff8fd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
set -xeuo pipefail
1818

1919
# Install deps in a virtual env.
20-
readonly VENV_DIR=/tmp/optax-env
21-
rm -rf "${VENV_DIR}"
22-
python3 -m venv "${VENV_DIR}"
20+
mkdir -p _testing
21+
VENV_DIR="$(mktemp -d -p `pwd`/_testing optax-env.XXXXXXXX)"
22+
# in the unlikely case in which there was something in that directory
23+
python3 -m venv --copies "${VENV_DIR}"
2324
source "${VENV_DIR}/bin/activate"
2425
python --version
2526

2627
# Install dependencies.
2728
pip install --upgrade pip setuptools wheel
28-
pip install flake8 pytest-xdist pylint pylint-exit
29+
pip install flake8 pytest pylint pylint-exit
2930
pip install -e ".[test, examples]"
3031

3132
# Dp-accounting specifies exact minor versions as requirements which sometimes
@@ -63,13 +64,13 @@ python -m build
6364
pip wheel --verbose --no-deps --no-clean dist/optax*.tar.gz
6465
pip install optax*.whl
6566

66-
# Check types with pytype.
67+
# # Check types with pytype.
6768
pip install pytype
68-
pytype `find optax/_src/ examples optax/contrib -name '*.py' | xargs` -k -d import-error
69+
pytype `find optax/_src examples optax/contrib -name '*.py' | xargs` -k -d import-error
6970

7071
# Run tests using pytest.
7172
# Change directory to avoid importing the package from repo root.
72-
mkdir _testing && cd _testing
73+
mkdir cd _testing
7374
python -m pytest -n auto --pyargs optax
7475
cd ..
7576

0 commit comments

Comments
 (0)