8484# ----------------------------
8585echo " === Building Wheel Package ==="
8686EXECUTORCH_BUILDING_WHEEL=1 python setup.py bdist_wheel
87-
8887unset EXECUTORCH_BUILDING_WHEEL
8988
9089WHEEL_FILE=$( ls dist/* .whl | head -n 1)
@@ -103,18 +102,6 @@ else
103102 echo " OK: No qualcomm/sdk files found in wheel"
104103fi
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
129116fi
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
156196echo " === All tests completed! ==="
0 commit comments