Version 2 (modified by Chris Jerdonek, 13 years ago) (diff)

Minor updates. Added a FIXME to include upgrade instructions.

WebKit Python Guidelines and Tips

Here is an overview of WebKit's use of Python.

  • Most of the Python code is in WebKitTools/Scripts/webkitpy.
  • WebKitTools/Scripts also contains some Python code in the form of end-user scripts. Generally, we try to keep as much of the code in webkitpy as possible since this allows the code to be organized more nicely, for unit tests to be in companion files, etc.
  • Unit test files are in correspondence with modules. For example, if is the name of a module, its unit test file would be and would lie in the same directory.
  • Informally, we try to follow PEP8.
  • We put all third-party Python code in webkitpy/thirdparty.
  • Scripts/test-webkitpy unit tests the Python code.
  • Most of WebKit's Python scripts require Python 2.5 to run.

Upgrading Python

FIXME: fill in this section.

Mac OS X Snow Leopard

(This section may not be necessary. WebKit is still discussing what Python versions we need to support.)

Python 2.4 is not officially installed or supported on Snow Leopard (Mac OS X 10.6). Because of this, you may need to install Python 2.4 yourself. After installing MacPorts, you should be able to install Python 2.4 and python_select as follows (roughly). python_select allows you to quickly go back and forth between Python versions:

  • Type sudo port install python24
  • Type sudo port install python_select
  • Then you should be able to type select Python 2.4 using, for example,sudo python_select python24.
  • Use python_select -l to find out what versions are available on your machine.