Skip to content

Commit cf6426d

Browse files
committed
docs: add documentation on how to upgrade Python
1 parent 95770e4 commit cf6426d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/technotes.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,59 @@ broke OpenSSL in our build environment. Projects like Alpine Linux appear
9191
to still be able to build OpenSSL 1.1.1c. It requires certain headers
9292
to be in place though. When we tried to work around this, it turned out to
9393
be easier to compile with LibreSSL than with OpenSSL.
94+
95+
Upgrading CPython
96+
=================
97+
98+
This section documents some of the work that needs to be performed
99+
when upgrading CPython major versions.
100+
101+
Review Release Notes
102+
--------------------
103+
104+
CPython's release notes often have a section on build system changes.
105+
e.g. https://docs.python.org/3/whatsnew/3.8.html#build-and-c-api-changes.
106+
These are a must review.
107+
108+
``Modules/Setup``
109+
-----------------
110+
111+
The ``Modules/Setup`` file defines the default extension build settings
112+
for *boring* extensions which are always compiled the same way.
113+
114+
We need to audit it for differences such as added/removed extensions,
115+
changes to compile settings, etc just in case we have special code
116+
handling an extension defined in this file.
117+
118+
See code in ``cpython.py`` dealing with this file.
119+
120+
``setup.py`` / ``static-modules``
121+
---------------------------------
122+
123+
The ``setup.py`` script in the Python source distribution defines
124+
logic for dynamically building C extensions depending on environment
125+
settings.
126+
127+
Because we don't like what this file does by default in many cases,
128+
we have instead defined static compilation invocations for various
129+
extensions in ``static-modules.*`` files. Presence of an extension
130+
in this file overrides CPython's ``setup.py`` logic. Essentially what
131+
we've done is encoded what ``setup.py`` would have done into our
132+
``static-modules.*`` files, bypassing ``setup.py``.
133+
134+
This means that we need to audit ``setup.py`` every time we perform
135+
an upgrade to see if we need to adjust the content of our
136+
``static-modules.*`` files.
137+
138+
A telltale way to find added extension is to look for ``.so`` files
139+
in ``python/install/lib/pythonX.Y/lib-dynload``. If an extension
140+
exists in a static build, it is being built by ``setup.py`` and
141+
we may be missing an entry in our ``static-modules.*`` files.
142+
143+
The most robust method to audit changes is to run a build of CPython
144+
out of a source checkout and then manually compare the compiler
145+
invocations for each extension against what exists in our
146+
``static-modules.*`` files. Differences like missing source files
147+
should be obvious, as they usually result in a compilation failure.
148+
But differences in preprocessor defines are more subtle and can
149+
sneak in if we aren't careful.

0 commit comments

Comments
 (0)