Python 3 in Heptapod 0.13

By Octobus

A few days ago, Heptapod 0.13.0rc2 was released.

This is the first version with optional support for Python 3.

Detailed version information in Heptapod 0.13.0rc2 help page

In this post, we explain why it matters to test Heptapod with Python 3 as soon as possible, and how to do so safely for your Heptapod instance.

Running with Python 3 should not change anything from users perspective, but it's an important landmark for the sustainability of the Heptapod project and it's been a fair amount of work.

Because we expect issues that could be related to the move to Python 3 to be non obvious, we've decided to support both Python versions for at least the whole Heptapod 0.13 development cycle, so that any given instance can be switched back to Python 2 easily.

By running Heptapod with Python 3, you would help the Heptapod project moving forward, while gaining better confidence that your use cases will be well supported in the upcoming versions that may drop the support for Python 2.

Of course Python 3 will be tested extensively on the instances managed by Octobus and Clever Cloud.

Docker: running with Python 3

Starting with Heptapod 0.13.0rc2, we have two series of Docker images:

  • octobus/heptapod:0.13.0rc2-py2
  • octobus/heptapod:0.13.0rc2-py3
  • octobus/heptapod:latest-py2
  • octobus/heptapod:latest-py3

Running with Python 3 is as simple as using the py3 image.

There's no difference among these images except the Python version. If you encounter trouble that could be related to Python 3, simply restart with the py2 image and compare the outcome.

The default image (octobus/heptapod:latest or octobus/heptapod:0.13.0rc2) still points to the py2 variant. If we get satisfactory results, we may change that to the py3 variant for Heptapod 0.13.1 or 0.13.2.

It's not clear at this time if Heptapod 0.14 can have Python 2 support. In any case Python 3 will be the default.

Source installations and Python 3

In a source installation, it's up to you to decide which Python interpreter will have the Heptapod Python components (including Mercurial), but we still advise to be ready to switch easily between Python 2 and 3.

From 0.13.0rc2 onwards, the install instructions include a recommended deployment strategy meant precisely for easily switching Python version, with almost no interruption of service.

Some background

Mercurial is written primarily in the Python programming language. Python 2 has reached its end of life this year. The new version of the language, Python 3, has a vastly different and incompatible way of handling strings and their encodings. This is challenging for a version control system which, by definition, must be able to handle content transparently, even if it doesn't have a known and consistent encoding. The change of type can cause mismatches in seldom used code paths in libraries. This could for example be triggered by communicating with external systems with unusual characteristics.

Python 3 support in Mercurial has been progressing gradually in recent releases, and we believe 5.4 on Python 3 to be ready enough for inclusion in Heptapod. Also, the last blocker on the road towards Python 3 has been removed with the port of hg-git to Python 3.

By Octobus