Confirmed users
1,989
edits
| (6 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
This page collects links and resources to assist the migration of the Firefox ecosystem off of Python 2 and onto Python 3. | |||
== Why This is Important == | == Why This is Important == | ||
In mozilla-central there are over 3500 Python files (excluding third party files), comprising roughly 230k lines of code. Most of it is Python 2.[https://ahal.ca/blog/2019/python-3-at-mozilla/] | In mozilla-central there are over 3500 Python files (excluding third party files), comprising roughly 230k lines of code. Most of it is Python 2.[https://ahal.ca/blog/2019/python-3-at-mozilla/] | ||
Python 2 will reach it's End Of Life on January 1st 2020. | Python 2 will reach it's End Of Life on '''[https://www.python.org/doc/sunset-python-2/ January 1st 2020]''' (here's [https://pythonclock.org/ a countdown!]). | ||
== What Will Happen If We Don't Upgrade? == | |||
The [https://www.python.org/doc/sunset-python-2/ PSF said it best]: | |||
<blockquote style="background-color: #F0F0FF; padding: 1em">"If people find catastrophic security problems in Python 2, or in software written in Python 2, then most volunteers will not help fix them. If you need help with Python 2 software, then many volunteers will not help you, and over time fewer and fewer volunteers will be able to help you. You will lose chances to use good tools because they will only run on Python 3, and you will slow down people who depend on you and work with you. | |||
Some of these problems will start on January 1. Other problems will grow over time." | |||
</blockquote> | |||
== How We Get There == | == How We Get There == | ||
| Line 21: | Line 32: | ||
=== Find the others === | === Find the others === | ||
Most discussion happens in the # | Most discussion happens in the #py3 channel on Slack (NDA'd Mozillians only). You can also join #python on irc.mozilla.org. | ||
=== What you'll need === | === What you'll need === | ||
| Line 31: | Line 42: | ||
==== Remove more of the "excluded" paths from the py2 and py3 linters ==== | ==== Remove more of the "excluded" paths from the py2 and py3 linters ==== | ||
See [https://pad.mozilla.org/p/py3 this Etherpad] for instructions. | See [https://pad.mozilla.org/p/py3 this Etherpad] for instructions. (Etherpad is blank, needs to be fixed) | ||
Roughly: | Roughly: | ||
* Pick a directory [https://pad.mozilla.org/p/py3 from the list], and put your name beside it so we know it's ported | * Pick a directory [https://pad.mozilla.org/p/py3 from the list], and put your name beside it so we know it's ported (this etherpad is now blank, ask in #py3 for details) | ||
* Edit py2.yml and/or py3.yml and remove that directory from the exclusion list | * Edit py2.yml and/or py3.yml and remove that directory from the exclusion list (from tools/lint/py2.yml and tools/lint/py3.yml in https://hg.mozilla.org/mozilla-central/) | ||
* Run `./mach lint -l py2 -l py3 <your directory name>` to get a list of errors | * Run `./mach lint -l py2 -l py3 <your directory name>` to get a list of errors | ||
* To get a list of files that need fixing: | * To get a list of files that need fixing: | ||
| Line 52: | Line 63: | ||
# Set one of callek, ahal, or catlee as the code reviewer | # Set one of callek, ahal, or catlee as the code reviewer | ||
==== | ==== Enable Python 3 on more Python unittests ==== | ||
Python unittests are run with `./mach python-test` and are (usually) defined in `python.ini` files. To get a test running against Python 3: | |||
# Find a test that is skipped with Python 3, you can use [https://searchfox.org/mozilla-central/search?q=.*(skip|fail)-if.*python+%3F%3D%3D+%3F3&case=true®exp=true&path=.ini%24 this query] to find these tests. | |||
# Edit the manifest and remove the Python 3 skip-if annotation. | |||
# Run the test with `./mach python-test --python 3 path/to/test`. | |||
# Fix any errors and repeat the previous step. | |||
# Once it is passing locally, test it out on try. If there is no Python 3 task running this manifest already, you'll need to add one by adding `3` to the `python-version` key in [https://searchfox.org/mozilla-central/source/taskcluster/ci/source-test/python.yml python.yml]. | |||
# Push the task to try on all platforms it is configured for. | |||
==== Port a Mach Command ==== | ==== Port a Mach Command ==== | ||
The mach driver (toplevel `mach` file) contains a whitelist of commands that still run with Python 2. | The mach driver (toplevel `mach` file) contains a whitelist of commands that still run with Python 2. | ||
The whitelist contained in the mach command is py2commands | |||
py2commands=" | |||
addtest | |||
analyze | |||
android | |||
android-emulator | |||
artifact | |||
awsy-test | |||
bootstrap..." | |||
Pick the command that you'd like to convert and then: | |||
# Remove it from the whitelist | # Remove it from the whitelist | ||
# Run: ./mach <command> | # Run: ./mach <command> | ||