Chapter 2. Python Infrastructure

In building a house, there is the problem of the selection of wood.

It is essential that the carpenter’s aim be to carry equipment that will cut well and, when he has time, to sharpen that equipment.

Miyamoto Musashi (The Book of Five Rings)

For someone new to Python, Python deployment might seem all but straightforward. The same holds true for the wealth of libraries and packages that can be installed optionally. First of all, there is not only one Python. Python comes in many different flavors, like CPython, Jython, IronPython, or PyPy. Then there is still the divide between Python 2.7 and the 3.x world. This chapter focuses on CPython, the most popular version of the Python programming language, and on version 3.8.

Even when focusing on CPython 3.8 (henceforth just “Python”), deployment is made difficult due to a number of reasons:

  • The interpreter (a standard CPython installation) only comes with the so-called standard library (e.g. covering typical mathematical functions).

  • Optional Python packages need to be installed separately, and there are hundreds of them.

  • Compiling (“building”) such non-standard packages on your own can be tricky due to dependencies and operating system–specific requirements.

  • Taking care of such dependencies and of version consistency over time (maintenance) is often tedious and time consuming.

  • Updates and upgrades for certain packages might cause the need for recompiling a multitude of other packages.

Get Python for Algorithmic Trading now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.