[Buildroot] [PATCH 1/2] packge/pkg-python: drop custom environment variables

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu May 9 14:01:37 UTC 2024


On Tue,  7 May 2024 11:29:35 -0500
Vincent Fazio <vfazio at gmail.com> wrote:

> Many moons ago, in the dark ages of Python, cross compiles were largely
> unsupported. In these before-times, a patchset used by PtxDist [0] [1]
> was adapted to help make cross compiles work.
> 
> The patchset did a number of things but mainly:
>  1) used a build-machine compatible python interpreter for certain
>     stages of the target Python build process
>  2) made adjustments to certain files to make decisions based on values
>     set in environment variables instead of the path of the executing
>     Python interpreter.
> 
> Since the path of the interpreter that was build machine compatible was
> outside of the target build directory, the code that made assumptions
> about the location of headers and library paths being relative to the
> interpreter path needed to be adjusted, hence them being driven via
> environment variables.
> 
> The patchset worked by replacing the executable path to be the sysroot
> which included the python headers and libraries.
> 
> A number of issues regarding cross compilation [2] [3] [4] have since
> been closed since the introduction of this patchset and cross builds
> became much better supported starting in Python v3.3.1.
> 
> New logic primarily uses the _PYTHON_PROJECT_BASE env variable [5] [6].
> 
> When set properly, this drives a few things:
>   * flags a cross compile environment
>   * sysconfig.is_python_build = True which triggers:
>     * altered paths for finding the Makefile and config.h
>     * altered sysconfig.get_config_var("srcdir")
> 
> When migrating to Python 3.4, PtxDist reworked their patchset to use
> the standard environment variables for their cross compiles [7].
> 
> The distutils module was a primary consumer of the custom variables from
> the previous patchset, however, that module is deprecated and packages
> cannot target it as of 09de823c.
> 
> Package builds and unit tests seem to work without using these variables
> being set, implying they can likely be dropped. Packages that still use
> distutils should be updated to reflect its removal in 3.12.
> 
> Once these custom variables are removed, the following Python3 patches
> which leverage them can be dropped:
>   0004-Adjust-library-header-paths-for-cross-compilation
>   0009-Do-not-adjust-the-shebang-of-Python-scripts-for-cros
> 
> [0]: https://gitlab.vahanus.net/ptxdist/ptxdist/-/commit/eef994411c20653cde95b35266000e3a8754e3b3
> [1]: https://gitlab.vahanus.net/ptxdist/ptxdist/-/commit/6c79cb5ac373b1cccf531e8be3ed1b9722ed1622
> [2]: https://github.com/python/cpython/issues/48004
> [3]: https://github.com/python/cpython/issues/58538
> [4]: https://github.com/python/cpython/issues/59689
> [5]: https://github.com/python/cpython/commit/7e6c2e2cc49fa109662d3f04f4c3553596d31937
> [6]: https://github.com/python/cpython/commit/9731330d6f4d63d6d57c8e99c8d11ef1def42858
> [7]: https://gitlab.vahanus.net/ptxdist/ptxdist/-/commit/638a024500c214c1d8283bce8cec864fb95deacf
> 
> Signed-off-by: Vincent Fazio <vfazio at gmail.com>
> ---
>  package/pkg-python.mk | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the buildroot mailing list