Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 602580 - python_fix_shebang could introduce new shebang line to files lacking it
Summary: python_fix_shebang could introduce new shebang line to files lacking it
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-13 22:37 UTC by Martin Mokrejš
Modified: 2017-01-17 09:50 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Mokrejš 2016-12-13 22:37:53 UTC
It seems python_fix_shebang cannot prepend a shebang line to a pyhton script.

 * Package:    sci-biology/eval-2.2.8
 * Repository: science
 * Maintainer: mmokrejs@fold.natur.cuni.cz sci-biology@gentoo.org
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux python_targets_python2_7 userland_GNU
 * FEATURES:   nostrip preserve-libs sandbox splitdebug userpriv usersandbox
>>> Unpacking source...
>>> Unpacking eval-2.2.8.tar.gz to /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work
>>> Unpacking eval-documentation.pdf to /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work
unpack eval-documentation.pdf: file format not recognized. Ignoring.
>>> Source unpacked in /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work
>>> Preparing source in /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work/eval-2.2.8 ...
>>> Source prepared.
>>> Configuring source in /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work/eval-2.2.8 ...
>>> Source configured.
>>> Compiling source in /scratch/var/tmp/portage/sci-biology/eval-2.2.8/work/eval-2.2.8 ...
>>> Source compiled.
>>> Test phase [not enabled]: sci-biology/eval-2.2.8

>>> Install eval-2.2.8 into /scratch/var/tmp/portage/sci-biology/eval-2.2.8/image/ category sci-biology
 * python2_7: running python_doscript RangeFinder.py merge_gtf_transcripts.py
 * The file has incompatible shebang:
 *   file: /usr/lib/python-exec/python2.7/RangeFinder.py
 *   current shebang: """Container index by sequence id, range, and optionally strand that efficiently
 *   requested impl: python2.7
 * ERROR: sci-biology/eval-2.2.8::science failed (install phase):
 *   python_fix_shebang: conversion of incompatible shebang requested
 * 
 * Call stack:
 *     ebuild.sh, line  115:  Called src_install
 *   environment, line 3742:  Called python_foreach_impl 'python_doscript' 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line 3272:  Called multibuild_foreach_variant '_python_multibuild_wrapper' 'python_doscript' 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line 1997:  Called _multibuild_run '_python_multibuild_wrapper' 'python_doscript' 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line 1995:  Called _python_multibuild_wrapper 'python_doscript' 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line  468:  Called python_doscript 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line 2922:  Called python_doexe 'RangeFinder.py' 'merge_gtf_transcripts.py'
 *   environment, line 2883:  Called python_newexe 'RangeFinder.py' 'RangeFinder.py'
 *   environment, line 3503:  Called python_fix_shebang '-q' '/scratch/var/tmp/portage/sci-biology/eval-2.2.8/image//usr/lib/python-exec/python2.7/RangeFinder.py'
 *   environment, line 3251:  Called die
 * The specific snippet of code:
 *                   die "${FUNCNAME}: conversion of incompatible shebang requested";
 * 
 * If you need support, post the output of `emerge --info '=sci-biology/eval-2.2.8::science'`,
 * the complete build log and the output of `emerge -pqv '=sci-biology/eval-2.2.8::science'`.
 * The complete build log is located at '/scratch/var/tmp/portage/sci-biology/eval-2.2.8/temp/build.log'.
 * The ebuild environment file is located at '/scratch/var/tmp/portage/sci-biology/eval-2.2.8/temp/environment'.
 * Working directory: '/scratch/var/tmp/portage/sci-biology/eval-2.2.8/work/eval-2.2.8'
 * S: '/scratch/var/tmp/portage/sci-biology/eval-2.2.8/work/eval-2.2.8'
Comment 1 Mike Gilbert gentoo-dev 2016-12-13 22:41:35 UTC
That's really not the purpose of python_fix_shebang.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-12-13 22:55:21 UTC
Yeah, it would be inconsistent with other bits of how it operates -- e.g. that it rejects incompatible shebangs.
Comment 3 Mike Gilbert gentoo-dev 2016-12-13 23:08:17 UTC
In a pinch, you could use the following command to add a shebang, and then call python_fix_shebang to fix it.

sed -i -e '1i #!/usr/bin/env python' myscript || die
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-12-13 23:13:24 UTC
(In reply to Mike Gilbert from comment #3)
> In a pinch, you could use the following command to add a shebang, and then
> call python_fix_shebang to fix it.
> 
> sed -i -e '1i #!/usr/bin/env python' myscript || die

Or even:

  sed -i -e "1i #!/usr/bin/env ${EPYTHON}" myscript || die

and not have to fix it at all ;-P.
Comment 5 Martin Mokrejš 2017-01-08 16:39:54 UTC
(In reply to Michał Górny from comment #4)

> Or even:
> 
>   sed -i -e "1i #!/usr/bin/env ${EPYTHON}" myscript || die
> 
> and not have to fix it at all ;-P.

 * The file has incompatible shebang:
 *   file: /usr/lib/python-exec/python2.7/RangeFinder.py
 *   current shebang: #!/usr/bin/env 
 *   requested impl: python2.7
 * ERROR: sci-biology/eval-2.2.8::science failed (install phase):
 *   python_fix_shebang: conversion of incompatible shebang requested


IMHO 'python_foreach_impl python_doscript *.py' should have done this for me automagically. Some of the have a shebang line, one does not.
Comment 6 Martin Mokrejš 2017-01-17 09:50:54 UTC
(In reply to Michał Górny from comment #4)
> (In reply to Mike Gilbert from comment #3)
> > In a pinch, you could use the following command to add a shebang, and then
> > call python_fix_shebang to fix it.
> > 
> > sed -i -e '1i #!/usr/bin/env python' myscript || die
> 
> Or even:
> 
>   sed -i -e "1i #!/usr/bin/env ${EPYTHON}" myscript || die
> 
> and not have to fix it at all ;-P.

I failed with this so I had to let python_fix_shebang to fix it. See last two commits:

https://cgit.gentoo.org/proj/sci.git/commit/sci-biology/eval?id=91d9ac3dd8937f2091118f1f3ac1d638898445d9

https://cgit.gentoo.org/proj/sci.git/commit/sci-biology/eval?id=a4fd373b45de86b4a6b5d631c2a4ddc148e290eb

Seemed I have to include python-ditutils-r1 but then than I had to override src_compile as there is no setup.py, so I just puth there

#!/usr.bin/env python