Skip to content

Commit a5121a9

Browse files
rocm: fix pip-wheel detection across Python versions in install_rocjpeg.sh
importlib.util.find_spec only searches the current Python's sys.path. When the script runs inside a conda env (Python 3.10) but _rocm_sdk_devel is installed for the system Python (3.11), find_spec returns None and the skip check falls through to dnf install, which fails on ROCm 7.14. Add a glob fallback over /*/lib/python*/site-packages/ that finds _rocm_sdk_* regardless of which Python version it was installed for. The pattern is not conda-specific and works for any standard prefix. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 909d84b commit a5121a9

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packaging/install_rocjpeg.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ set -euo pipefail
1515

1616
# Skip if rocjpeg is already installed via the ROCm pip-wheel distribution
1717
# (ROCm >= 7.14: librocjpeg ships inside _rocm_sdk_core / _rocm_sdk_devel
18-
# site-packages). Use importlib to find the package regardless of the Python
19-
# environment (conda or not).
18+
# site-packages).
19+
#
20+
# Primary check: importlib.util.find_spec queries Python's import system and
21+
# works in any environment (conda, venv, system Python, etc.).
22+
# Fallback glob: handles the case where _rocm_sdk_* is installed for a
23+
# different Python version than the one running this script (e.g. the script
24+
# runs in a Python 3.10 conda env but _rocm_sdk_devel is under Python 3.11).
25+
# The pattern /*/lib/python*/site-packages covers standard install prefixes
26+
# (/opt/conda, /usr, /usr/local, etc.) without being conda-specific.
2027
if python3 -c "
21-
import importlib.util, pathlib, sys
28+
import importlib.util, pathlib, sys, glob
2229
for pkg in ('_rocm_sdk_core', '_rocm_sdk_devel'):
2330
spec = importlib.util.find_spec(pkg)
2431
if spec and spec.submodule_search_locations:
2532
pkg_root = pathlib.Path(list(spec.submodule_search_locations)[0])
2633
if (pkg_root / 'include' / 'rocjpeg' / 'rocjpeg.h').exists():
2734
sys.exit(0)
35+
if glob.glob('/*/lib/python*/site-packages/_rocm_sdk_*/include/rocjpeg/rocjpeg.h'):
36+
sys.exit(0)
2837
sys.exit(1)
2938
" 2>/dev/null; then
3039
echo "rocjpeg already installed via ROCm pip-wheel; skipping dnf install."

0 commit comments

Comments
 (0)