Firefox/Python 3 Migration: Difference between revisions
< Firefox
Jump to navigation
Jump to search
(tweak dates, tweak porting instructions) |
|||
| Line 14: | Line 14: | ||
* Make Python 3 porting and development safe by adding a Python 3 option to the developer toolchain. (mach lint, parts of the test suite) | * Make Python 3 porting and development safe by adding a Python 3 option to the developer toolchain. (mach lint, parts of the test suite) | ||
* Port Python 2-only components to Python 3 piecemeal. | * Port Python 2-only components to Python 3 piecemeal. | ||
* Remove Python 2 compatibility. (When that might happen needs discussion | * Remove Python 2 compatibility. (When that might happen needs discussion. Possibly sometime in 2020.) | ||
== Getting Involved == | == Getting Involved == | ||
| Line 30: | Line 30: | ||
** If using `tox`, then adding `py35`, and `py36` to the list of environments should be sufficient | ** If using `tox`, then adding `py35`, and `py36` to the list of environments should be sufficient | ||
** If using |mach python-test|, make sure the relevant manifest doesn't skip-if Python 3 and run |mach python-test --python 3 <path>|. | ** If using |mach python-test|, make sure the relevant manifest doesn't skip-if Python 3 and run |mach python-test --python 3 <path>|. | ||
* [http://python-future.org/futurize.html#stage-1-safe-fixes `futurize`] | * [http://python-future.org/futurize.html#stage-1-safe-fixes `futurize` Stage 1 fixes] can be used to transform code into code that's compatible with both python2.7 and python3 | ||
* The `six` module is available in-tree, feel free to use it as a dependency | * The `six` module is available in-tree, feel free to use it as a dependency | ||
Revision as of 18:49, 30 May 2019
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.[1]
Python 2 will reach it's End Of Life on January 1st 2020. This page collects links and resources to assist the migration of the Firefox ecosystem off of Python 2 and onto Python 3.
How We Get There
As of today (May 2019) we require both the Python 2 and Python 3 interpreters to be installed to build and develop Firefox.
Next we:
- Build interpreter switching mechanisms into the toolchain so we can run sub-components in just 2 or just 3. (mach sub-commands, py_action)
- Make Python 3 porting and development safe by adding a Python 3 option to the developer toolchain. (mach lint, parts of the test suite)
- Port Python 2-only components to Python 3 piecemeal.
- Remove Python 2 compatibility. (When that might happen needs discussion. Possibly sometime in 2020.)
Getting Involved
Find the others
Most discussion happens in the #python channel on Slack (NDA'd Mozillians only).
Find a place to start hacking
Bug 1496527 tracks the migration work across Firefox.
How to Port the Code
- Make sure you can test the code you're working on with python3!
- If using `tox`, then adding `py35`, and `py36` to the list of environments should be sufficient
- If using |mach python-test|, make sure the relevant manifest doesn't skip-if Python 3 and run |mach python-test --python 3 <path>|.
- `futurize` Stage 1 fixes can be used to transform code into code that's compatible with both python2.7 and python3
- The `six` module is available in-tree, feel free to use it as a dependency