Summary: | python_fix_shebang doesn't handle insane locations or EPREFIX | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Justin Lecher (RETIRED) <jlec> |
Component: | Current packages | Assignee: | Python Gentoo Team <python> |
Status: | RESOLVED OBSOLETE | ||
Severity: | normal | CC: | chewi, prefix |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Justin Lecher (RETIRED)
2015-09-04 09:06:57 UTC
(In reply to Justin Lecher from comment #0) > When changing shebang following sed call is run > > + [[ #!/usr/bin/python2 == *python2\ * ]] > + sed -i -e '1s:python2$:python2.7:' ......... > + any_fixed=1 > > Two Problematic cases here: > > in case of Gentoo Prefix this result of the correction is > > #!/usr/bin/python2.7 > > but it should be > > #!${EPREFIX}/usr/bin/python2.7 EPREFIX being insane would break the shebang. You should really use '/usr/bin/env python...' here. > > > Second case: > > original the shebang wasn't sane > > + [[ #!/foo/bar/python2 == *python2\ * ]] > + sed -i -e '1s:python2$:python2.7:' ............... > + any_fixed=1 > + set +x > > resulting in > > #!/foo/bar/python2.7 > > We need to exchange it to the full "${PYTHON}" You need to manually sed insane stuff. Guessing is unsafe. (In reply to Michał Górny from comment #1) > (In reply to Justin Lecher from comment #0) > > When changing shebang following sed call is run > > > > + [[ #!/usr/bin/python2 == *python2\ * ]] > > + sed -i -e '1s:python2$:python2.7:' ......... > > + any_fixed=1 > > > > Two Problematic cases here: > > > > in case of Gentoo Prefix this result of the correction is > > > > #!/usr/bin/python2.7 > > > > but it should be > > > > #!${EPREFIX}/usr/bin/python2.7 > > EPREFIX being insane would break the shebang. You should really use > '/usr/bin/env python...' here. /usr/bin/env python would work for us, but sometimes that's not possible, since you cannot pass any arguments to the python binary that way. Also, that usage is up to $UPSTREAM and $MAINTAINER? In our case we can assume $EPREFIX to be sane. If it isn't, then Portage is broken and you've got issues way before this. I personally like it over /usr/bin/env, for it eliminates the surprise factor in case $PATH isn't what it is supposed to be. > > Second case: > > > > original the shebang wasn't sane > > > > + [[ #!/foo/bar/python2 == *python2\ * ]] > > + sed -i -e '1s:python2$:python2.7:' ............... > > + any_fixed=1 > > + set +x > > > > resulting in > > > > #!/foo/bar/python2.7 > > > > We need to exchange it to the full "${PYTHON}" > > You need to manually sed insane stuff. Guessing is unsafe. That would be a $MAINTAINER problem, not Prefix specific then, am I right? I don't think this is an issue we like to persue any more. (In reply to Fabian Groffen from comment #3) > I don't think this is an issue we like to persue any more. Since there was a slight overlap here with how I was trying to handle cross-compiling of Python modules (long story), I'd like to know more about why you came to this decision. |