Fix a regression in include paths when compiling ctypes in 3.6.15/3.7.12 #2209
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In my previous work on getting Python 3.6.15 and 3.7.12 to compile on Apple M1, I backported logic from newer 3.8.x releases to properly find libffi and related files on macOS.
This regressed compilation on Linux. The include search path was incomplete, and
ffi.h
could not be found, resulting inctypes
being disabled.There was a key difference between the old logic and new logic that led to this regression:
detect_ctypes()
insetup.py
took no arguments, and was expected to access instance variables for the include search path.detect_ctypes()
took the path as an argument, and was expected to make use of it.The backport made use of the instance variables, overriding the provided include path. These were not equivalent. The one on the instance was not complete, lacking the necessary directories to find
ffi.h
. Since this could not be found,ctypes
support was disabled.The fix is to simply not overwrite the variables passed to the function, and resume using them as before.
Fixes #2207
Tests
Compiled 3.6.15 and 3.7.12 on macOS (M1).
Compiled 3.6.15 and 3.7.12 on Linux in a Docker image provided on #2207 that reproduced the failure case.
In all tested environments,
ctypes
compiled and could be imported successfully.