Skip to content

[Fix] Auto-detect Python executable in cmake utils#491

Merged
danieldk merged 3 commits intohuggingface:mainfrom
YangKai0616:local-build
Apr 21, 2026
Merged

[Fix] Auto-detect Python executable in cmake utils#491
danieldk merged 3 commits intohuggingface:mainfrom
YangKai0616:local-build

Conversation

@YangKai0616
Copy link
Copy Markdown
Contributor

@YangKai0616 YangKai0616 commented Apr 20, 2026

run_python(), run_python_script() and try_run_python() in utils.cmake previously hardcoded Python_EXECUTABLE or Python3_EXECUTABLE.

For example, this causes get_gpu_lang.py to fail with "Cannot detect GPU language" when building kernels locally via pip install -e ..

The error message is as follows:

...
running build_py
      running build_ext
      -- The CXX compiler identification is IntelLLVM 2025.3.2
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /opt/intel/oneapi/compiler/2025.3/bin/icpx - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- FetchContent base directory: /tmp/tmp5jy45gzj.build-temp/flash_attn2._flash_attn2_xpu_37cbe71_dirty/_deps
      -- Found Python3: /opt/venv/bin/python (found version "3.12.3") found components: Development Development.SABIModule Interpreter Development.Module Development.Embed
      CMake Error at cmake/utils.cmake:60 (message):
        Cannot detect GPU language:
      Call Stack (most recent call first):
        cmake/get_gpu_lang.cmake:5 (run_python_script)
        CMakeLists.txt:41 (get_gpu_lang)
...

This PR makes all three functions auto-detect the available Python executable.

@YangKai0616
Copy link
Copy Markdown
Contributor Author

Hi @danieldk , @drbh , pls help review. Thanks!

@YangKai0616 YangKai0616 changed the title [Fix] Use Python3_EXECUTABLE consistently in cmake utils [Fix] Auto-detect Python executable in cmake utils Apr 20, 2026
@YangKai0616
Copy link
Copy Markdown
Contributor Author

Hey @danieldk , we can re-trigger the CI. I’ve already tested both the local build and the nix build successfully.

Copy link
Copy Markdown
Member

@danieldk danieldk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Test failures are unrelated.

@danieldk danieldk merged commit 669ebab into huggingface:main Apr 21, 2026
51 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants