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 in `ctypes` being
disabled.
There was a key difference between the old logic and new logic that led
to this regression:
1. In 3.8 and newer, `detect_ctypes()` in `setup.py` took no arguments,
and was expected to access instance variables for the include search
path.
2. In 3.7 and earlier, `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
This change ports pyenv and Python patches to 3.7.12 to enable the
`ctypes `and `decimal` modules to compile.
While Python 3.7.12 itself compiles on arm64/M1, both of these modules
fail to compile, due to missing support for locating system libffi and
due to architecture gate-keeping. These issues have been fixed in newer
releases of Python, and in other pyenv patch bundles.
The following patches are provided:
1. `0001-Port-ctypes-and-system-libffi-patches-for-arm64-macO.patch` -
Fixes system `ffi.h`/`libffi` path determination and usage and
enables calling of variadic functions, fixing ctypes support
(consolidated port of existing pyenv patches for 2.7.18 that iterate
on this logic).
2. `0002-bpo-41100-fix-_decimal-for-arm64-Mac-OS-GH-21228.patch` -
Adds arm64 to the list of allowable architectures for the
`decimal` module (port of Python patch introduced in 3.8.10).
This change ports several established patches to the Python 3.6.15
build, enabling compilation on arm64/Apple M1 architectures:
1. `0001-Detect-arm64-in-configure.patch` -
Updates configure to detect arm64 architectures (port of an existing
pyenv patch for 2.7.18).
2. `0002-bpo-36231-Support-building-on-macOS-without-usr-incl.patch` -
Adds macOS SDK root computation logic for determining include paths
(port of existing Python patches introduced in 2.7.17 and 3.7.4).
3. `0003-Fix-macOS-_tkinter-use-of-Tck-Tk-in-Library-Framewor.patch` -
Fixes Tcl/Tk support on macOS (port of an existing pyenv patch
for 2.7.18).
4. `0004-Port-ctypes-and-system-libffi-patches-for-arm64-macO.patch` -
Fixes system `ffi.h`/`libffi` path determination and usage and
enables calling of variadic functions, fixing ctypes support
(consolidated port of existing pyenv patches for 2.7.18 that iterate
on this logic).
5. `0005-BPO-41100-Support-macOS-11-when-building-GH-21113.patch` -
Updates Darwin version checks to handle macOS 11's major version
bump (port of Python patches introduced in 3.7.0 and 3.9.0).
6. `0006-bpo-41100-fix-_decimal-for-arm64-Mac-OS-GH-21228.patch` -
Adds arm64 to the list of allowable architectures for the
`decimal` module (port of Python patch introduced in 3.8.10).
This is needed to find other Python deps (e.g. libintl) in Homebrew if it has
nonstandard prefix (e.g. in Apple M1)
* Re-allow to search Homebrew for zlib everywhere
Link to the active version like other Homebrew deps --
this won't break when another binary-compatible version is installed.
Use a discovery method that doesn't break when other versions are present alongside.
This is essentially the same fix as in pull request #2047, but it
is applied from Python 2.6.6 to 2.6.9, and for `ossaudiodev` as well
as the (deprecated) `linuxaudiodev`.
With the normal `setup.py`, the installation of the `ossaudiodev`
module is skipped under GNU/Linux with newer kernel versions because
Python 3.1 appends the major kernel version to the result of
`build_ext.get_platform` and later `ossaudiodev` is skipped if the
major kernel version is not 2. A similar problem might occur if
installing in FreeBSD.
This problem may even occur if installing Python 3.1 in a Docker image
of an old OS (e.g. prehistoric Debian or CentOS), because the major
kernel version is still the one of the host system.
The solution is to use `str.startswith` and only check that the
platform starts with 'linux' or 'freebsd'.
The original 2.3 portable version was compiled on Ubuntu 20.04 and didn't work with older glibc.
This has been fixed and the older file has been deleted so hopefully this change is acceptable.
Ensuring that all dirs in LDFLAGS exist is only needed for Ruby due to its `configure` requirements.
If some LDFLAGS entries point to a nonexisting path to which the user doesn't have permission. this causes a build failure.
In certain cases, a user wants to know the cached filename to add the file themselves,
see https://github.com/pyenv/pyenv/issues/1743 .
Since we report both a filename and a URL anyway, there's no reason to report a wrong one.
This behavior is only triggered when the version is provided as an empty string,
is undocumented and breaks if multiple local versions are specified
(rightly so since it's unclear which of them to install).
To support building for Apple ARM64 which was introduced in MacOS 11
OpenSSL added support for Apple ARM in 1.1.1
(61168b5b8d).
Python added support for MacOS 11 in 3.7.8+, 3.8.4+, 3.9.0+
(https://github.com/python/cpython/pull/21113 and backports).