Line
Link Here
|
0 |
-- python.eclass |
0 |
++ python.eclass |
Lines 774-779
Link Here
|
774 |
import sys |
774 |
import sys |
775 |
|
775 |
|
776 |
EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") |
776 |
EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") |
|
|
777 |
python_shebang_re = re.compile(r"^#!.*python") |
777 |
|
778 |
|
778 |
EOF |
779 |
EOF |
779 |
if [[ "$?" != "0" ]]; then |
780 |
if [[ "$?" != "0" ]]; then |
Lines 841-853
Link Here
|
841 |
fi |
842 |
fi |
842 |
cat << EOF >> "${file}" |
843 |
cat << EOF >> "${file}" |
843 |
|
844 |
|
844 |
os.environ["PYTHON_SCRIPT_NAME"] = sys.argv[0] |
845 |
wrapper_script_path = os.path.realpath(sys.argv[0]) |
845 |
target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI) |
846 |
target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI) |
846 |
if not os.path.exists(target_executable): |
847 |
os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0] |
847 |
sys.stderr.write("'%s' does not exist\n" % target_executable) |
848 |
os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path |
|
|
849 |
if not os.path.exists(target_executable_path): |
850 |
sys.stderr.write("'%s' does not exist\n" % target_executable_path) |
848 |
sys.exit(1) |
851 |
sys.exit(1) |
849 |
|
852 |
|
850 |
os.execv(target_executable, sys.argv) |
853 |
target_executable = open(target_executable_path, "rb") |
|
|
854 |
target_executable_first_line = target_executable.readline() |
855 |
if not isinstance(target_executable_first_line, str): |
856 |
# Python 3 |
857 |
target_executable_first_line = target_executable_first_line.decode("utf_8", "replace") |
858 |
|
859 |
python_shebang_matched = python_shebang_re.match(target_executable_first_line) |
860 |
target_executable.close() |
861 |
|
862 |
if python_shebang_matched: |
863 |
os.execv(wrapper_script_path, sys.argv) |
864 |
else: |
865 |
os.execv(target_executable_path, sys.argv) |
851 |
EOF |
866 |
EOF |
852 |
if [[ "$?" != "0" ]]; then |
867 |
if [[ "$?" != "0" ]]; then |
853 |
die "${FUNCNAME}(): Generation of '$1' failed" |
868 |
die "${FUNCNAME}(): Generation of '$1' failed" |