How to build MSI installer for Python 3.9.5 on Windows 10?

I am building the MSI installer for python 3.9.5 using
Tools\msi\build.bat -x64
But it says

LNK1104: cannot open file “libffi-7.lib”

I am using the following software versions:

  • git version 2.43.0.windows.1
  • Microsoft Visual Studio Enterprise 2019 version 16.11.33

The source code is downloaded from https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz. Does anyone have any ideas as to what might be going wrong and/or how to fix it?

Did you build libffi as part of providing the dependencies for python?

Thank you for your reply. I am compiling the source code for python 3.9.5 using Tools\msi\build.bat. But it said

Blockquote fatal error LNK1104: cannot open file “libffi-7.lib”

According to the original topic, I think there is something wrong with the code downloaded from https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz. And there is no python 3.9.5 source code in GitHub - python/cpython: The Python programming language, so I put forward this problem.

This doesn’t look related to the original question at all, and downloading that release of 3.11 would definitely not solve the problem. It looks like you simply don’t have a required dependency set up for compiling Python. Please start by reading about building Python in the main documentation, and/or check out the setup and building chapter in the development guide.

1 Like

It’s there: Release v3.9.5 · python/cpython · GitHub

FYI, there’s no need to keep editing your post over and over to try to get the formatting right. Instead, simply use the live preview pane right next to text box, which is exactly why it is there.

I’m curious as to the reason you’re compiling such an old feature version, and a particularly old patch version thereof (3.9.18 is the latest). Why not simply use the binary installers for that version (or compile a more recent one)?

That builds the MSI installer, not Python itself, which is normally something that only the release managers need to do, and you can get said installer already built for you on the Python.org download page.

According to the original topic, the error occurred on Python 3.11.0a1, and ended up being apparently user error. Furthermore, the title of this topic requested how to download that aforementioned version. Therefore, I don’t really understand why you’re asking this, sorry.

Sure there is; you just have to check out the corresponding tag after you’ve cloned the repo (git checkout v3.9.5) as I’ve previously stated, or you can view it online.

1 Like

Thank you for your reply. I got solution from Problems with building CPython - #4 by Thoufak. Actually, there is really something wrong with the downloaded source code of Python 3.9.5. I modified the following files according to bpo-45022: Pin current libffi build to fixed version in preparation f… · python/cpython@399cd46 · GitHub, and it works.

  • PCbuild/get_externals.bat
  • PCbuild/prepare_libffi.bat
  • PCbuild/python.props
1 Like

As mentioned previously, is there a reason you can’t simply use the latest patch 3.9 version, 3.9.18, as opposed the long-outdated 3.9.5? It fixes hundreds of bugs and security issues, including the build problem you encountered, while being a drop-in, backward-compatible replacement for 3.9.5.

(N.B., since you created another thread on this actual topic, and others were already trying to help you here when it was apparently solved already, I moved the relevant posts over here)