llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang analyzer script's python interpreter is not configurable

Open dannf opened this issue 8 months ago • 3 comments

The clang analyzer scripts (analyze-build, intercept-build and scan-build. Install with a non-configurable #!/usr/bin/env python3 shebang. The clang python module builds for whatever version of python it finds at build-time. So if /usr/bin/python3 is 3.14 at build-time, but then later becomes 3.15, those scripts will not find a module to import. Please make this shebang configurable, possibly via the -DPYTHON_EXECUTABLE cmake flag.

Our use case: On wolfi/Chainguard OS systems, we provide multiple /usr/bin/python3.x versions concurrently, and we try to configure all OS commands to use a #!/usr/bin/env python3.x shebang instead of making assumptions about python3. This allows /usr/bin/python3 free to point to whatever the end-user/application prefers (or to not exist at all).

dannf avatar Apr 02 '26 22:04 dannf

@llvm/issue-subscribers-clang-static-analyzer

Author: dann frazier (dannf)

The clang analyzer scripts (`analyze-build`, `intercept-build` and `scan-build`. Install with a non-configurable `#!/usr/bin/env python3` shebang. The `clang` python module builds for whatever version of `python` it finds at build-time. So if `/usr/bin/python3` is `3.14` at build-time, but then later becomes `3.15`, those scripts will not find a module to import. Please make this shebang configurable, possibly via the `-DPYTHON_EXECUTABLE` `cmake` flag.

Our use case: On wolfi/Chainguard OS systems, we provide multiple /usr/bin/python3.x versions concurrently, and we try to configure all OS commands to use a #!/usr/bin/env python3.x shebang instead of making assumptions about python3. This allows /usr/bin/python3 free to point to whatever the end-user/application prefers (or to not exist at all).

llvmbot avatar Apr 02 '26 22:04 llvmbot

I’d like to work on this.

My current plan is to make the Python shebang used by scan-build-py configurable from CMake, instead of hardcoding #!/usr/bin/env python3, while keeping the current default behavior unchanged. I think this should cover the installed entry-point scripts as well as the related wrapper scripts under libexec, so they all use the same interpreter choice.

Lane0218 avatar Apr 03 '26 03:04 Lane0218

I guess it makes sense, but I'm just a regular user of python. Definitely not a power user.

steakhal avatar Apr 07 '26 19:04 steakhal