Closed Bug 1714688 Opened 3 years ago Closed 3 years ago

Remove `if PY2`/`if PY3` logic now that we never use Python 2 with Mach

Categories

(Firefox Build System :: General, task, P3)

task

Tracking

(firefox91 fixed)

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: mhentges, Assigned: surajeet310)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug)

Attachments

(7 files, 6 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

When run with ./mach, if PY2 will always be False, and if PY3 will always be True. Let's simplify accordingly.

Note: some Python scripts may be run via mozharness, and such tasks may still be using Python 2. When that's the case, report (or find) a bug to run the task with Python 3 instead, resolve that first, then come back to removing PY2/PY3 usages.

Keywords: good-first-bug
Priority: -- → P3
Assignee: nobody → surajeet310
Status: NEW → ASSIGNED

Note that, in all the cases where PY2 and PY3 come from six, they are able to be automatically handled by pyupgrade.

Can you tell me where should I begin @mhentges ?

Sure thing Surajeet:
First, you can see the list of if PY2/if PY3 instances on SearchFox here. Note that anything under third_party/python and testing/web-platform/tests/ are 3rd-party code and shouldn't be changed in your patches. (EDIT as mentioned by ahal, tooltool.py is 3rd-party code too, and also shouldn't be updated).

Next, I'd recommend breaking down your patches to be specific to components: e.g. update testing/mozharness in one patch, and testing/mozbase in another, and python/mozbuild in another, and so on. Each time you complete a patch, send it in, and I can start reviewing.
Does that make sense?

Yes, it does @mhentges :)
Let me start ,I will let you know if I have any doubts on the way :)
Thank you !

Attachment #9226475 - Attachment description: Bug 1714688 -Removed 'if PY2' logic .r=mhentges → Bug 1714688 - Removed 'if PY2' logic from mozglue r=mhentges

Python2 is no longer used in Mozbuild.

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1d869c7669e6
Removed 'if PY2' logic from mozglue r=mhentges
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Python2 is no longer used in Mozrelease

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/15c6a16f5828
Removed 'if PY2'/'if PY3' logic from python/mozbuild r=mhentges

Python 2 is no longer used in js/src

Backed out for docker images bustage

${PIP_PATH} install mercurial-4.8.1.tar.gz
else
echo "Do not know how to install Mercurial on this OS"
exit 1
fi
Traceback (most recent call last):
File "/tmp/tooltool.py", line 66, in <module>
import urllib.request as urllib2
ImportError: No module named request
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
Error: Could not build image.
[taskcluster 2021-06-14 17:31:10.673Z] === Task Finished ===
[taskcluster 2021-06-14 17:31:10.750Z] Artifact "public/image.tar.zst" not found at "/workspace/image.tar.zst"
[taskcluster 2021-06-14 17:31:10.905Z] Unsuccessful task run with exit code: 1 completed in 31.675 seconds

Flags: needinfo?(surajeet310)
Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9f0fbb143172
Removed 'if PY2' logic from js/src r=mhentges
Attachment #9226645 - Attachment is obsolete: true

Python2 is no longer used in Mozrelease

Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/177ac92fb734
Fix lint black failure r=fix CLOSED TREE
Attachment #9226910 - Attachment is obsolete: true
Attachment #9226645 - Attachment is obsolete: false
Depends on: 1716390
No longer depends on: 1716390
Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8c07e39f8dbd
Removed 'if PY2' logic from python/mozrelease r=mhentges

Removed the changes for tooltool.py

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ceac5a7590de
Removed 'if PY2'/'if PY3' logic from python/mozbuild r=mhentges

Python2 is no longer used in testing/condprofile

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7cd82eea9af2
Removed 'if PY3' logic from testing/condprofile r=mhentges

Python2 is no longer used in testing/marionette

Python2 is no longer used in testing/mozbase

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/74fd8bb17de0
Removed 'if PY3' logic from testing/mozbase r=mhentges

Python2 is no longer used in testing/tools

Python2 is no longer used in testing/mozharness

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/52c33043778a
Removed 'if PY2' logic from testing/marionette r=mhentges,webdriver-reviewers,jgraham
Flags: needinfo?(surajeet310)

The file 'websocketprocessbridge_requirements_3.txt' has been renamed to 'websocketprocessbridge_requirements.txt' as Python2 is no longer used.

Attachment #9227703 - Attachment description: Bug 1714688 - Removed 'if PY2' logic from testing/mozharness r=mhentges → Bug 1714688 - Removed unnecessary postfix '_3' from 'websocketprocessbridge_requirements_3.txt' r=mhentges
Attachment #9227703 - Attachment is obsolete: true
Attachment #9227492 - Attachment is obsolete: true

Python2 is no longer used in testing/mozharness. Hence,all the instances of file 'websocketprocessbridge_requirements.txt' are removed as it is obsolete now.

Attachment #9227480 - Attachment is obsolete: true

Now that only the file 'websocketprocessbridge_requirements.txt' is used, so the qualifier '_3' is redundant.

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/941f6c6c51e3
Removed 'if PY2' logic from testing/mozharness r=mhentges
https://hg.mozilla.org/integration/autoland/rev/997f00815e6b
Removed unnecessary postfix '_3' from 'websocketprocessbridge_requirements_3.txt' r=mhentges
Regressed by: 1717578
No longer regressed by: 1717578
Regressions: 1717578

Let's mark this as fixed since all remaining if PY2/PY3 code is in:

  • third_party/python/
  • tooltool
  • testing/web-platform/tests/
  • Mozilla tests that may still be using Python 2.

Great work Surajeet in making the possible cleanups! Big 🎉 :)

Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Flags: needinfo?(surajeet310)
Resolution: --- → FIXED
See Also: → 1717651, 1717649
See Also: → 1714406
Depends on: 1714406
Attachment #9227827 - Attachment is obsolete: true
Attachment #9227751 - Attachment is obsolete: true
Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/050c73c280e8
Removed 'if PY3' logic from testing/tools r=mhentges
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: