Problems with building CPython

I’m trying to build python 3.9.5, but it fails with the following error:

LINK : fatal error LNK1181: cannot open input file 'libffi-7.lib' [C:\Users\ss2\Desktop\cpython-3.9.5\PCbuild\_ctypes.v cxproj]

I’m using these build instructions: cpython/readme.txt at main · python/cpython · GitHub.
So basically I installed the Visual Studio (2022) and the required components, and ran the PCBuild/build.bat.

This is the full output of the build.bat: Using py -3.9 (found 3.9 with py.exe)Fetching external libraries...Fetching - Pastebin.com

I’m running Windows 11 64-bit and an ARM-based processor.

Please let me know if I missed any important details.

The source code was downloaded from here: Release v3.9.5 · python/cpython · GitHub

I would assume that you need to build all the dependencies that python needs.
In this case you need to build libffi. The srouces are on http://sourceware.org/libffi (according to the Fedora Linux RPM).

Also that is not the latest version of the source code for 3.9 is there a reason not to use the latest version of 3.9 or even 3.10?

Thank you for the reply.

I think the build instructions would say, if I needed to build anything separately. Moreover, the output of the build.bat says Fetching libffi.... So it seems it should download (and build?) the libffi itself. I’m not sure why the needed file isn’t present then.

Regarding the python version. I already have the python 3.9.5 on my PC. I want the same version, just with some changes.

I see that Fedora is using libffi ABI 8 and your error was for ABI 7.
Do you see any version of libffi that was built?
Maybe you have to get an old version of libffi to go with the old python 3.9.

You are running with a lot of know security issues and bugs then.
I recommend that if you have a problem with 3.10 then update to the security release 3.9.14.

You may also find that it might work with newer libffi.

The issue is that v3.9.5 did not pin libffi to a particular version in get_externals.bat, but rather downloaded from the libffi branch. If you cherry-pick commit 399cd466d03, the build should work as expected.

2 Likes

Thank you so much! It worked.

1 Like