This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Feature request: option to keep/add flags to pathfix.
Type: enhancement Stage: resolved
Components: Demos and Tools Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: hroncok, pkopkan, vstinner
Priority: normal Keywords: patch

Created on 2019-05-27 13:09 by pkopkan, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13591 closed pkopkan, 2019-05-27 13:13
PR 15548 merged pkopkan, 2019-08-27 12:51
PR 15705 merged vstinner, 2019-09-05 15:43
PR 15717 merged pkopkan, 2019-09-06 13:56
PR 16387 merged vstinner, 2019-09-25 12:46
PR 16389 merged vstinner, 2019-09-25 13:45
Messages (10)
msg343622 - (view) Author: Patrik Kopkan (pkopkan) * Date: 2019-05-27 13:09
Hello,
Pathfix is nice simple tool for changing shebang lines. However, it is lacking a way how to keep/add flags making this tool impractical sometimes.
msg343628 - (view) Author: Patrik Kopkan (pkopkan) * Date: 2019-05-27 14:10
Example:
pathfix.py -i /usr/bin/python ./directory --> would change the shebang of
every script in this directory recursively to #! /usr/bin/python. That's handy but if you would have script like this: #! /usr/bin/env -flags and
wanted to keep the flags.
You would need to run again pathfix: pathfix.py -i '/usr/bin/python -flags' ./directory. That is not that bad for one script but with increasing number of scripts, differences of flags between the scripts it gets harder.
msg351202 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-05 14:55
New changeset 50254ac4c179cb412e90682098c97db786143929 by Victor Stinner (PatrikKopkan) in branch 'master':
bpo-37064: Add option -k to Tools/scripts/pathfix.py (GH-15548)
https://github.com/python/cpython/commit/50254ac4c179cb412e90682098c97db786143929
msg351206 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-05 15:37
The newly added test fails if Python is installed:

https://buildbot.python.org/all/#/builders/188/builds/927

======================================================================
FAIL: test_pathfix (test.test_tools.test_pathfix.TestPathfixFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/python3.9/test/test_tools/test_pathfix.py", line 36, in test_pathfix
    self.pathfix(
  File "/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/python3.9/test/test_tools/test_pathfix.py", line 24, in pathfix
    self.assertEqual(proc.returncode, 0, proc)
AssertionError: 2 != 0 : CompletedProcess(args=['/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/bin/python3.9', '/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/Tools/scripts/pathfix.py', '-i', '/usr/bin/python3', '-n', '@test_1589863_tmp'], returncode=2, stdout=b'', stderr=b"/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/bin/python3.9: can't open file '/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/Tools/scripts/pathfix.py': [Errno 2] No such file or directory\n")

======================================================================
FAIL: test_pathfix_keeping_flags (test.test_tools.test_pathfix.TestPathfixFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/python3.9/test/test_tools/test_pathfix.py", line 50, in test_pathfix_keeping_flags
    self.pathfix(
  File "/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/python3.9/test/test_tools/test_pathfix.py", line 24, in pathfix
    self.assertEqual(proc.returncode, 0, proc)
AssertionError: 2 != 0 : CompletedProcess(args=['/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/bin/python3.9', '/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/Tools/scripts/pathfix.py', '-i', '/usr/bin/python3', '-k', '-n', '@test_1589863_tmp'], returncode=2, stdout=b'', stderr=b"/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/bin/python3.9: can't open file '/home/buildbot/buildarea/3.x.cstratak-fedora.installed/build/target/lib/Tools/scripts/pathfix.py': [Errno 2] No such file or directory\n")
msg351212 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-05 16:09
New changeset 3f43ceff186da09978d0aff257bb18b8ac7611f7 by Victor Stinner in branch 'master':
bpo-37064: Skip test_tools.test_pathfix if installed (GH-15705)
https://github.com/python/cpython/commit/3f43ceff186da09978d0aff257bb18b8ac7611f7
msg353186 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-25 12:26
New changeset 1dc1acbd73f05f14c974b7ce1041787d7abef31e by Victor Stinner (PatrikKopkan) in branch 'master':
bpo-37064: Add option -a to pathfix.py tool (GH-15717)
https://github.com/python/cpython/commit/1dc1acbd73f05f14c974b7ce1041787d7abef31e
msg353190 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-25 12:48
I wrote PR 16387 to backport pathfix changes from Python 3.8. The changes add tests which make me confident that it's safe to backport the changes. Currently, pathfix has no test at all in Python 3.8.
msg353193 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-25 13:22
New changeset c71c54c62600fd721baed3c96709e3d6e9c33817 by Victor Stinner in branch '3.8':
bpo-37064: Add -k and -a options to pathfix.py tool (GH-16387)
https://github.com/python/cpython/commit/c71c54c62600fd721baed3c96709e3d6e9c33817
msg353194 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-25 13:23
Thanks Patrik Kopkan for your contributions! It's now part of 3.8 and master branches. Your work will be part of the incoming Python 3.8.0 final release.
msg353201 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-25 14:12
New changeset 2e566bf35e96f0d6ca6fe291f179e832d1c32186 by Victor Stinner in branch '3.8':
bpo-37064: Skip test_tools.test_pathfix if installed (GH-15705) (GH-16389)
https://github.com/python/cpython/commit/2e566bf35e96f0d6ca6fe291f179e832d1c32186
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81245
2019-09-25 14:12:35vstinnersetmessages: + msg353201
2019-09-25 13:45:25vstinnersetpull_requests: + pull_request15971
2019-09-25 13:23:39vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg353194

stage: patch review -> resolved
2019-09-25 13:22:43vstinnersetmessages: + msg353193
2019-09-25 12:48:05vstinnersetmessages: + msg353190
2019-09-25 12:46:09vstinnersetpull_requests: + pull_request15969
2019-09-25 12:26:43vstinnersetmessages: + msg353186
2019-09-06 13:56:00pkopkansetpull_requests: + pull_request15371
2019-09-05 16:09:49vstinnersetmessages: + msg351212
2019-09-05 15:43:38vstinnersetpull_requests: + pull_request15359
2019-09-05 15:37:19vstinnersetmessages: + msg351206
2019-09-05 14:55:01vstinnersetnosy: + vstinner
messages: + msg351202
2019-08-27 12:51:09pkopkansetpull_requests: + pull_request15225
2019-05-27 14:10:31pkopkansetmessages: + msg343628
2019-05-27 13:38:58SilentGhostsettype: enhancement
2019-05-27 13:16:06hroncoksetnosy: + hroncok
2019-05-27 13:15:32hroncoksetcomponents: + Demos and Tools
versions: + Python 3.8, Python 3.9
2019-05-27 13:13:59pkopkansetkeywords: + patch
stage: patch review
pull_requests: + pull_request13497
2019-05-27 13:09:47pkopkancreate