Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 505354

Summary: python-single-r1: python_fix_shebang shouldn't (always?) fail on incompatible shebangs
Product: Gentoo Linux Reporter: Christoph Mende (RETIRED) <angelos>
Component: EclassesAssignee: Python Gentoo Team <python>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Christoph Mende (RETIRED) gentoo-dev 2014-03-22 14:55:20 UTC
I hit this while writing an ebuild that installs a file with a python3 sheband. Said file also works perfectly fine with python2. Calling python_fix_shebang fails though when PYTHON_SINGLE_TARGET is set to 2.x.
This can currently only be worked around by:
a) setting PYTHON_COMPAT to python3_* only, forcing the user to change PYTHON_SINGLE_TARGET
b) sedding the python3 shebang to "python", so python_fix_shebang can properly replace it with the user-chosen implementation

Ideally, python_fix_shebang should work without the sed. I also cannot think of any case where the fatal die would be useful. Except to stop people from pushing something they didn't test on all PYTHON_COMPAT versions.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-03-22 19:45:21 UTC
Why would upstream use 'python3' shebang on script that works in Python 2? The check is there to avoid mistakes.
Comment 2 Christoph Mende (RETIRED) gentoo-dev 2014-03-22 21:13:45 UTC
No idea, I'd guess because they prefer python3 or come from a platform where there's only python2 and python3, not python. At least that's the case for pastebinit-1.4.1 where I had to use the sed workaround.
Like I said, avoiding mistakes is the only reason I found, but I don't think letting a script die is a good way to hint at possible mistakes when there's perfectly valid scenarios.
Comment 3 Christoph Mende (RETIRED) gentoo-dev 2014-03-22 21:17:27 UTC
Another possible solution to this would be a --force parameter or something like that. That would make the developer writing the ebuild think twice about what he's doing and still give him the chance to use python_fix_shebang.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-06-19 08:08:21 UTC
+  19 Jun 2014; Michał Górny <mgorny@gentoo.org> python-r1.eclass,
+  python-utils-r1.eclass, tests/python-utils-r1.sh:
+  Improve handling of corner cases in python_fix_shebang. Support --force and
+  --quiet options, bug #505354. Add tests.