[New-bugs-announce] [issue28833] cross compilation of third-party extension modules

Xavier de Gaye report at bugs.python.org
Tue Nov 29 09:51:40 EST 2016


New submission from Xavier de Gaye:

With this patch, cross compiling a third-party extension module is done with the command:

  XBUILD_PYTHON_DIR=/path/to/python/dir python setup.py build

where XBUILD_PYTHON_DIR is the location of the directory of the cross-compiled python executable.
It may be:
a) The build tree, which is the source tree when the cross compilation is not out of the source tree.
b) '$DESTDIR/$exec_prefix/bin' when the cross built python has been installed with 'make DESTDIR=/some/path install'. In that case 'prefix' and 'exec_prefix' may be different.
c) When the result of the cross compilation has been manually copied (for example to /some/path) and if 'prefix' and 'exec_prefix' are identical, this is /some/path/bin.
In case b), one can use the 'install' setup.py command instead of the 'build' command, to build and install the extension module to '$DESTDIR/$exec_prefix/lib/python$VERSION/site-packages' with the appropriate 'egg-info' file.

The patch uses the 'python-config' shell script (created at issue 16235 [1]) that is initialized with the proper variables at the configure stage to provide the minimum information required by the sysconfig module to create (with the option --generate-posix-vars) the sysconfigdata file or to import the sysconfigdata module.
The patch also fixes issue 22724 [2] as sys.path is only modified during the time needed to import the sysconfigdata module.

The patch fixes two minor problems:
* '_PYTHON_HOST_PLATFORM' in Makefile.pre.in was not added to the sysconfig variables as intended, since those variables may not be prefixed with an underscore.
* The sysconfigdata file name was terminated with a dangling underscore when 'multiarch' is not defined.
Patch also tested with pyephem on an Android emulator.
The patch misses the documentation.
Please run autoconf after installing the patch.

[1] issue 16235: add python-config.sh for use during cross compilation
    http://bugs.python.org/issue16235
[2] issue 22724: byte-compile fails for cross-builds
    http://bugs.python.org/issue22724

----------
assignee: xdegaye
components: Cross-Build
files: cross-build-extension.patch
keywords: patch
messages: 281993
nosy: Alex.Willmer, doko, dstufft, eric.araujo, haypo, martin.panter, xdegaye, zach.ware
priority: normal
severity: normal
stage: patch review
status: open
title: cross compilation of third-party extension modules
type: behavior
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45688/cross-build-extension.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28833>
_______________________________________


More information about the New-bugs-announce mailing list