External libraries and Generated files

Add a new C file

To add a C file (.c) or an header file (.h), you have to:

  • Create Python/config.c

  • Add it to Makefile.pre.in: in PYTHON_OBJS for example

  • Add it to PCbuild/pythoncore.vcxproj

  • Add it to PCbuild/pythoncore.vcxproj.filters

When creating a new directory, see also:

  • For header files, see also Tools/msi/dev/dev.wixproj (read Steve Dower’s comment).

  • “make tags” and “make TAGS” in Makefile.pre.in

New subdirectories created in Lib/ must be added to LIBSUBDIRS of Makefile.pre.in (example).

New subdirectories created in Lib/test/ must be added to TESTSUBDIRS of Makefile.pre.in. The Windows installer copies Lib/test/ and subdirectories: see <InstallFiles Include="$(PySourcePath)Lib\test\**\*" ...> in Tools/msi/test/test.wixproj.

To build a new _testclinic_limited extension (Modules/_testclinic_limited.c) on Windows:

  • In PCbuild/, copy _asyncio.vcxproj to _testclinic_limited.vcxproj, replace RootNamespace with _testclinic_limited, replace _asyncio.c with _testclinic_limited.c.

  • Open Visual Studio, open PCbuild\pcbuild.sln, add the existing PCbuild\_testclinic_limited.vcxproj project to the solution.

  • Add a dependency from python project to the _testclinic_limited project.

  • Save and exit Visual Studio.

  • Add ;_testclinic_limited to <TestModules Include="..."> in PCbuild\pcbuild.proj.

Add a new subdirectory

If the subdirectory contains C code (.c files), it may be interesting to add it to SUBDIRS in configure.ac, so make tags will also parse these files to build the index used by some text editors.

Add a new C extension

  • Update setup.py

  • Update Modules/Setup

Generated files

  • make regen-all

  • autoconf: Regenerate configure from configure.ac

  • install-sh: rm install-sh; automake --add-missing --copy, https://bugs.python.org/issue34765

  • Lib/distutils/command/wininst-*.exe files are binaries of the PC/bdist_wininst/ program (in Python source code).

  • The frozen __phello module comes from M___hello__ constant in Python/frozen.c. The bytecode is generated by Tools/freeze/freeze.py Tools/freeze/flag.py.

  • Python/dtoa.c is based on http://www.netlib.org/fp/dtoa.c

  • Unicode: Update the Unicode version in the Tools/unicode/makeunicodedata.py script, run it, and fix what fails (msg318935).

  • Lib/keyword.py: https://bugs.python.org/issue36143

Vendored external libraries

Update dependencies: https://github.com/python/cpython-source-deps/blob/master/README.rst

See my external_versions.py script: external version of embedded libraries from CPython source code (locally).

On security branches, some dependencies are outdated because no more macOS nor Windows installer is built. It was decided to not upgrade outdated zlib 1.2.5 in Python 3.3.7, since it’s specific to Windows, and no Windows user is expected to build his/her own Python 3.3 anymore.

See also cpython-bin-deps and cpython-source-deps.