Opened 4 weeks ago

Last modified 4 weeks ago

#13505 new Patch - Feature

Rewrite python shebangs during 'make install' step

Reported by: rcrdnalor Owned by: Raymond Wagner
Priority: minor Milestone: needs_triage
Component: Bindings - Python Version: Master Head
Severity: medium Keywords: python shebang
Cc: Ticket locked: no

Description

This patch is a follow up to ticket #13504: Feature patch - clean up (dead) QMAKE_COPY_DIR code

As outlined in #13504, we need to set the python shebangs according to the configured python version for each installation.

Python's PEP 394 already defines the usage of shebangs in respect of the configured python version:

On recent linux distributions, the shebang #!/usr/bin/env python may not exist anymore and package install scripts already warn about 'ambiguous python shebang' during packaging.

This patch rewrites the shebang of python scripts during the 'make install' step of mythtv's 'metadata' scripts located in 'mythtv/programs/scripts' according the given python version. It ignores scripts that are set intentionally to python2.

It can be easily expanded to other folders like 'hardwareprofile' or 'internetcontent'.

Please note: This script looks like somehow 'quick and dirty', but i tried other solutions like creating an 'intermediate target' for the python scripts, and they are much more complicated than this one, albeit, I don't speak QMAKE well.

Attachments (1)

0001-Rewrite-python-shebangs-during-make-install-step.patch (5.5 KB) - added by rcrdnalor 4 weeks ago.
Patch that rewrites python shebangs not pointing to a specific python version

Download all attachments as: .zip

Change History (3)

Changed 4 weeks ago by rcrdnalor

Patch that rewrites python shebangs not pointing to a specific python version

comment:1 in reply to:  description Changed 4 weeks ago by Gary Buhrmaster

Replying to rcrdnalor:

This patch rewrites the shebang of python scripts during the 'make install' step of mythtv's 'metadata' scripts located in 'mythtv/programs/scripts' according the given python version.

I will note that some packaging systems (Fedora) have a tool included that recursively fixes python shebangs called pathfix.py which implements something similar, but almost certainly slightly different. It might be worth reviewing how it does its work to see how/if it can be utilized. Docs are at: https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error#Using_pathfix.py_to_fix_shebangs

FWIW, my rpm spec files all use pathfix.py to adjust the python to either python2 or python3 depending on target python version.

comment:2 Changed 4 weeks ago by rcrdnalor

Maybe I was not precise enough in the description of this ticket:

QMAKE allows a custom step only at the beginning of the INSTALLS target step: This is defined by the .extra stanza and gets called *before* the files/folders are actually installed. Running a script like 'pathfix.py' at this time over the source paths will modify the git sources unconditionally. This has to be avoided, because it is impractical.

I simply do not know how to run a script over the installed files *at the end* of the QMAKE INSTALLS target.

I would really prefer to have a standardized step here instead of a custom copy/rewrite script.

But as I said already, I do not know QMAKE well. Help is appreciated.

Note: See TracTickets for help on using tickets.