75
edits
(→How to Port the Code: add porting resources) |
(porting instruction updates) |
||
| Line 28: | Line 28: | ||
== How to Port the Code == | == How to Port the Code == | ||
=== Before starting === | |||
If you haven't ported modules before (or need a refresher), read the [https://docs.python.org/3/howto/pyporting.html Porting Guide on python.org]. It has a good outline of the porting process. | |||
=== Porting modules in the Firefox source tree === | |||
* We've already standardized on Python 2.7 across the tree. | |||
* Make sure you can test the code you're working on with python3! | * 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 `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` Stage 1 fixes] can be used to transform code into code that's compatible with both python2.7 and python3 | * [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. | ||
* [https://black.readthedocs.io/en/stable/index.html Black] can format Python 2 code and Python 3 code (but [https://black.readthedocs.io/en/stable/installation_and_usage.html it requires Py3.6+ to run]). | |||
=== Resources === | === Resources === | ||
[ | [https://docs.python.org/3/howto/pyporting.html Porting Guide on python.org] | ||
[ | [http://python-future.org/compatible_idioms.html Cheat Sheet: Writing Python 2-3 compatible code]. Note: misses some advanced changes, like porting __eq__() to __hash__() and changes to the slice interface. | ||
== References == | == References == | ||
edits