2

I have a similar issue to the one I was able to solve in here, when building Python3.9.2 in docker container the build finish successfully but ctypes is missing

ModuleNotFoundError: No module named '_ctypes'

Trying the same method in the above post did not worked, I even tried to install the latest libffi-3.3 with the same results, all the libffi headers and libs are in place.

It seems that only the _ctypes_test shared object was build.

root@74f1b419ddd8:/# find / -name _ctypes*
/usr/local/lib/python3.9/lib-dynload/_ctypes_test.cpython-39-x86_64-linux-gnu.so

I found some tickets regarding this but nothing worked for me:

Any idea how I can make it work for the latest Python 3.9?

Update: Tested on Python 3.7.10 & 3.8.8 and it seems to work fine so it probably something that changed on 3.9.*

Update2: I took the _ctypes.cpython-39-x86_64-linux-gnu.so file from a prebuilt docker pyhton:3.9.2-slim and put it in my container at /usr/local/lib/python3.9/lib-dynload/_ctypes_test.cpython-39-x86_64-linux-gnu.so and it worked, import ctypes did not raised this error (I had to build python with libffi-3.2.1 and not 3.3). Why I can't get make to build _ctypes?

Amir Rossert
  • 1,003
  • 2
  • 13
  • 33
  • Maybe it is having a hard time finding libffi? – Hood Jun 23 '21 at 22:12
  • Probably but I can’t get the build to find it – Amir Rossert Jun 26 '21 at 03:42
  • Maybe you could use `Modules/Setup.local`? I got it to work with this in `Setup.local`: `CTYPES_FLAGS=-DHAVE_FFI_PREP_CIF_VAR=1 -DHAVE_FFI_PREP_CLOSURE_LOC=1 -DHAVE_FFI_CLOSURE_ALLOC=1\n _ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/cfield.c _ctypes/stgdict.c $(CTYPES_FLAGS)\n _ctypes_test _ctypes/_ctypes_test.c ` – Hood Jun 26 '21 at 03:51
  • Probably you'll get linker errors due to missing libffi, but they are more helpful than it just silently not including ctypes. – Hood Jun 26 '21 at 03:53

0 Answers0