blob: 04050f7dabe172864eb68f9b412fcf730548bf86 [file] [log] [blame]
Stéphane Wirtelcbb64842019-05-17 11:55:34 +02001.. highlight:: c
Nick Coghlan7d82c862013-03-07 23:14:44 +10002
3.. _apiabiversion:
4
5***********************
6API and ABI Versioning
7***********************
8
Miss Islington (bot)37393712021-05-13 22:29:09 -07009CPython exposes its version number in the following macros.
10Note that these correspond to the version code is **built** with,
11not necessarily the version used at **run time**.
Nick Coghlan7d82c862013-03-07 23:14:44 +100012
Miss Islington (bot)37393712021-05-13 22:29:09 -070013See :ref:`stable` for a discussion of API and ABI stability across versions.
Nick Coghlan7d82c862013-03-07 23:14:44 +100014
Miss Islington (bot)37393712021-05-13 22:29:09 -070015.. c:macro:: PY_MAJOR_VERSION
Nick Coghlan7d82c862013-03-07 23:14:44 +100016
Miss Islington (bot)37393712021-05-13 22:29:09 -070017 The ``3`` in ``3.4.1a2``.
18
19.. c:macro:: PY_MINOR_VERSION
20
21 The ``4`` in ``3.4.1a2``.
22
23.. c:macro:: PY_MICRO_VERSION
24
25 The ``1`` in ``3.4.1a2``.
26
27.. c:macro:: PY_RELEASE_LEVEL
28
29 The ``a`` in ``3.4.1a2``.
30 This can be ``0xA`` for alpha, ``0xB`` for beta, ``0xC`` for release
31 candidate or ``0xF`` for final.
32
33.. c:macro:: PY_RELEASE_SERIAL
34
35 The ``2`` in ``3.4.1a2``. Zero for final releases.
36
37.. c:macro:: PY_VERSION_HEX
38
39 The Python version number encoded in a single integer.
40
41 The underlying version information can be found by treating it as a 32 bit
42 number in the following manner:
43
44 +-------+-------------------------+-------------------------+--------------------------+
45 | Bytes | Bits (big endian order) | Meaning | Value for ``3.4.1a2`` |
46 +=======+=========================+=========================+==========================+
47 | 1 | 1-8 | ``PY_MAJOR_VERSION`` | ``0x03`` |
48 +-------+-------------------------+-------------------------+--------------------------+
49 | 2 | 9-16 | ``PY_MINOR_VERSION`` | ``0x04`` |
50 +-------+-------------------------+-------------------------+--------------------------+
51 | 3 | 17-24 | ``PY_MICRO_VERSION`` | ``0x01`` |
52 +-------+-------------------------+-------------------------+--------------------------+
53 | 4 | 25-28 | ``PY_RELEASE_LEVEL`` | ``0xA`` |
54 + +-------------------------+-------------------------+--------------------------+
55 | | 29-32 | ``PY_RELEASE_SERIAL`` | ``0x2`` |
56 +-------+-------------------------+-------------------------+--------------------------+
57
58 Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is
59 hexversion ``0x030a00f0``.
60
Nick Coghlan7d82c862013-03-07 23:14:44 +100061
62All the given macros are defined in :source:`Include/patchlevel.h`.