basho/riak_pb — pull request #104 by javajolt (2014-11-12 22:50:26+00:00)
Title: Add support for Python 3

Python Makefile targets were broken into two different versions: Python 2 and Python 3. The original ``python_compile``, ``python_clean`` and ``python_release`` are relatively unchanged except that they now build in the ``python`` subdirectory instead of the default ``build`` subdirectory. Additional targets now include ``python3_compile``, ``python3_clean`` and ``python3_release`` which build in the ``python3`` subdirectory. Local installation targets ``python_install`` and ``python3_install`` were added to aid in local testing.

``msgcodegen.py`` was modified to run under Python 3.x and to massage the ``protoc``-generated PB files to run under Python 3 as well. The big issue here was that the metaclass syntax changed drastically in Python 3, so the ``six`` package is used to bridge versions 2 and 3. Also, relative module paths changed in Python 3, so full module paths are now used instead.

For whatever reason, local versions built against Python 2.6 did not work correctly nor did Python 3.3. However it looks like previously the Python 2.7 egg was released as Python 2.6, which continues to work. The same technique seems to work on the Python 3 side: build under Python 3.4, and install on Python 3.3.

Note: The uploading to PyPI has not been tested yet and ``python3_riak_pb`` has not been created there either.