I've got some Python scripts that are now being run by a wide variety of folks across multiple test platforms. This creates a problem for 2 reasons:
- The python3 path is not the same across all the testers, and
- Not all of the people running the scripts have a path to Python set in $PATH.
Because of (1) I can't hard-code the shebang since its tester dependent and because of (2) #!/usr/bin/env python3 isn't guaranteed to work if placed at the top of Python file.
I know that the python3 interpreter is going to be in one of a few locations across the testers. So what I'm wondering, is it possible to replace the #!/usr/bin/env python3 at the top of the Python file with a call to a bash shell script that looks for the python location and then "sets" it for the script? If that's not possible, then the rest of this is moot.
I created a bash script that does look through the possible locations until it finds the interpreter, but what I don't know how to do is return it in the top of a Python file.
For example, I created a basic python file (shebang.py)
#!./pyshebang.sh print("Hello World") pyshebang.sh does 2 things, it appends the found python path to PATH, and echo's back that path to the interpreter. If I run the python script above, stdout gets the echo from the bash script, but not the print from the python script.
python setup.py ...replaces any shebang containing the wordpython(with#!pythonbeing the minimal example) with the path specified by the installer./usr/bin/env python3doesn't merely echo back a path to bash. If you type/usr/bin/env python3directly on the command line, you'll see that it actually starts python (most likely via some flavor ofexec()). So presumably your script would have to do the same when called.execveman page: you can't put a script as the shebang.