classification
Title: Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out
Type: behavior Stage: patch review
Components: Demos and Tools Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, hroncok
Priority: normal Keywords: patch

Created on 2018-02-20 11:06 by hroncok, last changed 2018-03-14 17:52 by christian.heimes.

Pull Requests
URL Status Linked Edit
PR 5772 merged hroncok, 2018-02-20 11:13
PR 6103 merged miss-islington, 2018-03-13 09:58
PR 6104 merged miss-islington, 2018-03-13 09:58
Messages (5)
msg312411 - (view) Author: Miro Hrončok (hroncok) * Date: 2018-02-20 11:06
We (Fedora's Python SIG) would like to promote usage of Tools/scripts/pathfix.py (we've even moved it to $PATH) in Fedora RPM build (a.k.a spec files) instead of various error prone finds + greps + seds.

However when running pathfix.py, it creates backup files (with ~ suffix). This is mostly unfortunate in RPM build environment, because one needs to clean those up, otherwise one gets warnings and errors like this:


error: Installed (but unpackaged) file(s) found:
   /usr/bin/spam~


Or the file with ~ might even get installed if a more relaxed patter is used in a %files section that lists what is part of the RPM package.

    %{_bindir}/spam-*


We even have shebangs checks/mangling in place and the ~ suffixed file still has the wrong shebang, resulting in warnings like this:

*** WARNING: mangling shebang in /usr/bin/spam~ from #!/usr/bin/python -Es to #!/usr/bin/python2 -Es. This will become an ERROR, fix it manually!



Steps to Reproduce:
1. $ echo '#!python' > omg
2. $ Tools/scripts/pathfix.py -i "/usr/bin/python3" -p omg  # possibly with extra flag, see bellow
omg: updating
3. $ ls

Actual results: omg  omg~


Expected results: omg



Since the backup feature was here for ages, instead of changing the behavior, I suggest a flag is added that disables this. 2to3 has exactly the proposed flag as: "-n, --nobackups       Don't write backups for modified files".

This doesn't necessarily need to go into all versions, but I've selected all that has this problem. Getting it to 3.6+ would be great, however if it goes to anything later, we'll backport it in the Fedora package.


I have a patch ready, sill send PR.
msg312412 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-02-20 11:25
It's technically a new feature. But since it's just in Tools/, we could make an exception. I've removed the security branches from versions.
msg313736 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-03-13 09:56
New changeset 5affd5c29eb1493cb31ef3cfdde15538ac134689 by Christian Heimes (Miro Hrončok) in branch 'master':
bpo-32885: Tools/scripts/pathfix.py: Add -n option for no backup~ (#5772)
https://github.com/python/cpython/commit/5affd5c29eb1493cb31ef3cfdde15538ac134689
msg313829 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-03-14 17:52
New changeset a954919788f2130076e4f9dd91e9eccf69540f7a by Christian Heimes (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-32885: Tools/scripts/pathfix.py: Add -n option for no backup~ (GH-5772) (#6104)
https://github.com/python/cpython/commit/a954919788f2130076e4f9dd91e9eccf69540f7a
msg313830 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-03-14 17:52
New changeset 6e65e4462692cbf4461c307a411af7cf40a1ca4a by Christian Heimes (Miss Islington (bot)) in branch '3.7':
[3.7] bpo-32885: Tools/scripts/pathfix.py: Add -n option for no backup~ (GH-5772) (#6103)
https://github.com/python/cpython/commit/6e65e4462692cbf4461c307a411af7cf40a1ca4a
History
Date User Action Args
2018-03-14 17:52:31christian.heimessetmessages: + msg313830
2018-03-14 17:52:25christian.heimessetmessages: + msg313829
2018-03-13 09:58:53miss-islingtonsetpull_requests: + pull_request5867
2018-03-13 09:58:03miss-islingtonsetpull_requests: + pull_request5866
2018-03-13 09:56:45christian.heimessetmessages: + msg313736
2018-02-20 11:25:39christian.heimessetnosy: + christian.heimes

messages: + msg312412
versions: - Python 3.4, Python 3.5
2018-02-20 11:13:28hroncoksetkeywords: + patch
stage: patch review
pull_requests: + pull_request5551
2018-02-20 11:09:42hroncoksettype: behavior
2018-02-20 11:09:24hroncoksetcomponents: + Demos and Tools
2018-02-20 11:06:48hroncokcreate