Skip to content

Commit 12d19a1

Browse files
committed
add different pyhton version and virtual env
1 parent 79bd3c8 commit 12d19a1

File tree

2 files changed

+78
-33
lines changed

2 files changed

+78
-33
lines changed

.ci/scripts/test_wheel_package_qnn.sh

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ EOF
8484
# ----------------------------
8585
echo "=== Building Wheel Package ==="
8686
EXECUTORCH_BUILDING_WHEEL=1 python setup.py bdist_wheel
87-
8887
unset EXECUTORCH_BUILDING_WHEEL
8988

9089
WHEEL_FILE=$(ls dist/*.whl | head -n 1)
@@ -103,18 +102,6 @@ else
103102
echo "OK: No qualcomm/sdk files found in wheel"
104103
fi
105104

106-
# ----------------------------
107-
# Conda environment setup & tests
108-
# ----------------------------
109-
TEMP_ENV_DIR=$(mktemp -d)
110-
echo "Using temporary directory: $TEMP_ENV_DIR"
111-
112-
conda create -y -p "$TEMP_ENV_DIR/env" python=3.10
113-
conda run -p "$TEMP_ENV_DIR/env" pip install "$WHEEL_FILE"
114-
115-
conda run -p "$TEMP_ENV_DIR/env" pip install torch=="2.9.0.dev20250801" --index-url "https://download.pytorch.org/whl/nightly/cpu"
116-
conda run -p "$TEMP_ENV_DIR/env" pip install --pre torchao --index-url "https://download.pytorch.org/whl/nightly/cpu"
117-
118105
# ----------------------------
119106
# Check .so files in the wheel
120107
# ----------------------------
@@ -129,28 +116,81 @@ else
129116
fi
130117

131118
# ----------------------------
132-
# Check installed .so files in conda env
119+
# Helpers
133120
# ----------------------------
134-
echo "Checking installed executorch/backends/qualcomm/python contents in conda env..."
135-
ENV_SO_DIR="$TEMP_ENV_DIR/env/lib/python3.10/site-packages/executorch/backends/qualcomm/python"
136-
ls -l "$ENV_SO_DIR" || echo "Folder does not exist!"
121+
get_site_packages_dir () {
122+
local PYBIN="$1"
123+
"$PYBIN" - <<'PY'
124+
import sysconfig, sys
125+
print(sysconfig.get_paths().get("purelib") or sysconfig.get_paths().get("platlib"))
126+
PY
127+
}
128+
129+
run_core_tests () {
130+
local PYBIN="$1" # path to python
131+
local PIPBIN="$2" # path to pip
132+
local LABEL="$3" # label to print (conda/venv)
133+
134+
echo "=== [$LABEL] Installing wheel & deps ==="
135+
"$PIPBIN" install --upgrade pip
136+
"$PIPBIN" install "$WHEEL_FILE"
137+
"$PIPBIN" install torch=="2.9.0.dev20250801" --index-url "https://download.pytorch.org/whl/nightly/cpu"
138+
"$PIPBIN" install --pre torchao --index-url "https://download.pytorch.org/whl/nightly/cpu"
139+
140+
echo "=== [$LABEL] Import smoke tests ==="
141+
"$PYBIN" -c "import executorch; print('executorch imported successfully')"
142+
"$PYBIN" -c "import executorch.backends.qualcomm; print('executorch.backends.qualcomm imported successfully')"
143+
144+
echo "=== [$LABEL] List installed executorch/backends/qualcomm/python ==="
145+
local SITE_DIR
146+
SITE_DIR="$(get_site_packages_dir "$PYBIN")"
147+
local SO_DIR="$SITE_DIR/executorch/backends/qualcomm/python"
148+
ls -l "$SO_DIR" || echo "Folder does not exist!"
149+
150+
echo "=== [$LABEL] Run export script to generate linear.pte ==="
151+
(cd "$REPO_ROOT" && "$PYBIN" "$REPO_ROOT/script.py")
152+
153+
if [ -f "$REPO_ROOT/linear.pte" ]; then
154+
echo "[$LABEL] Model file linear.pte successfully created"
155+
else
156+
echo "ERROR: [$LABEL] Model file linear.pte was not created"
157+
exit 1
158+
fi
159+
}
137160

138-
# Run import tests
139-
conda run -p "$TEMP_ENV_DIR/env" python -c "import executorch; print('executorch imported successfully')"
140-
conda run -p "$TEMP_ENV_DIR/env" python -c "import executorch.backends.qualcomm; print('executorch.backends.qualcomm imported successfully')"
161+
# ----------------------------
162+
# Conda environment setup & tests
163+
# ----------------------------
164+
echo "=== Testing in Conda env ==="
165+
TEMP_ENV_DIR=$(mktemp -d)
166+
echo "Using temporary directory for conda: $TEMP_ENV_DIR"
167+
conda create -y -p "$TEMP_ENV_DIR/env" python=3.10
168+
# derive python/pip paths inside the conda env
169+
CONDA_PY="$TEMP_ENV_DIR/env/bin/python"
170+
CONDA_PIP="$TEMP_ENV_DIR/env/bin/pip"
171+
# Some images require conda run; keep pip/python direct to simplify path math
172+
run_core_tests "$CONDA_PY" "$CONDA_PIP" "conda"
173+
174+
# Cleanup conda env
175+
conda env remove -p "$TEMP_ENV_DIR/env" -y || true
176+
rm -rf "$TEMP_ENV_DIR"
177+
178+
# ----------------------------
179+
# Python venv setup & tests
180+
# ----------------------------
181+
echo "=== Testing in Python venv ==="
182+
TEMP_VENV_DIR=$(mktemp -d)
183+
echo "Using temporary directory for venv: $TEMP_VENV_DIR"
184+
python3 -m venv "$TEMP_VENV_DIR/venv"
185+
VENV_PY="$TEMP_VENV_DIR/venv/bin/python"
186+
VENV_PIP="$TEMP_VENV_DIR/venv/bin/pip"
141187

142-
# Run the dynamically created script using absolute path
143-
conda run -p "$TEMP_ENV_DIR/env" python "$REPO_ROOT/script.py"
188+
# Ensure venv has wheel/build basics if needed
189+
"$VENV_PIP" install --upgrade pip
144190

145-
# Check if linear.pte was created
146-
if [ -f "linear.pte" ]; then
147-
echo "Model file linear.pte successfully created"
148-
else
149-
echo "ERROR: Model file linear.pte was not created"
150-
fi
191+
run_core_tests "$VENV_PY" "$VENV_PIP" "venv"
151192

152-
# Cleanup
153-
conda env remove -p "$TEMP_ENV_DIR/env" -y
154-
rm -rf "$TEMP_ENV_DIR"
193+
# Cleanup venv
194+
rm -rf "$TEMP_VENV_DIR"
155195

156196
echo "=== All tests completed! ==="

.github/workflows/pull.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,29 @@ concurrency:
1414

1515
jobs:
1616
test-qnn-wheel-packages-linux:
17-
name: test-qnn-wheel-packages-linux
17+
name: test-qnn-wheel-packages-linux (py${{ matrix.python-version }})
1818
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1919
permissions:
2020
id-token: write
2121
contents: read
2222
strategy:
2323
fail-fast: false
24+
matrix:
25+
python-version: [ "3.10", "3.11", "3.12" ]
2426
with:
2527
runner: linux.2xlarge
2628
docker-image: ci-image:executorch-ubuntu-22.04-clang12
2729
submodules: 'recursive'
2830
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2931
timeout: 180
3032
script: |
31-
# The generic Linux job chooses to use base env, not the one setup by the image
3233
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
3334
conda activate "${CONDA_ENV}"
3435
36+
# Create a clean env for each python version
37+
conda create -y -n test_env_${{ matrix.python-version }} python=${{ matrix.python-version }}
38+
conda activate test_env_${{ matrix.python-version }}
39+
3540
PYTHON_EXECUTABLE=python bash .ci/scripts/test_wheel_package_qnn.sh
3641
3742
# test-setup-linux-gcc:

0 commit comments

Comments
 (0)