Skip to content

Idiomatic way to use python scripts in custom_target and similar. #10978

Answered by eli-schwartz
LunarLambda asked this question in Q&A
Discussion options

You must be logged in to vote

On Windows, script files are by definition non-executable. On Linux, they are non-executable if they don't have the executable bit.

In both cases, Meson will open up the file and scan it for a shebang on the first line, and run the script using the interpreter specified in the shebang. If that interpreter ends in "python3", (including if the shebang uses /usr/bin/env) it will use Meson's own sys.executable as the interpreter.

On Linux, if the file has the executable bit, it is simply run as is, which works in most cases, probably even NixOS, as long as you use env to cope with the BSDs where python is in /usr/local/bin, and NixOS where it is presumably inside a store path somewhere and ma…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@LunarLambda
Comment options

@eli-schwartz
Comment options

@vpoinot
Comment options

@eli-schwartz
Comment options

Answer selected by LunarLambda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants