ltib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ltib] Building Python 2.7


From: Mike Goins
Subject: Re: [Ltib] Building Python 2.7
Date: Tue, 30 Oct 2012 14:49:38 -0400

On Tue, Oct 30, 2012 at 12:17 AM, Reiko <address@hidden> wrote:
>
> Hello,
>
> Has anyone been able to build a recent Python version (e.g. 2.7) using
> LTIB?

I haven't tried a newer version, but I am very familiar with the
python in ltib (and cross compiling it).   I've been working on a
variation that installs a host version of python in ltib and then uses
that to build the cross-python.   I have it generally working, but I
haven't been able gather the list of requirements to properly take
into account variations between distros (fails on some machines but
not others.

Attached is a patch (based on 2.4), that does the above if you want to
give it a try for 2.7.  This avoids the ephemeral bootstrap and allows
host-python to build other python modules in other packages, like
python bindings for libxml, libxslt, jonpy, pyserial, modpython, etc.
 In order for it to be "complete" (that is, not try to use any native
host resources), it would also require having the host ltib packages
installed that python depends on (not yet done).

I haven't posted this to ltib since there is one thing I haven't got
quite fixed, building 32-bit python on 64-bit host.  We actually the
order is,  building 32-bit host [litb] python on 64-bit host that is
used to build a 32-bit cross-python without picking up anything from
the native python (which is all to easy, but is 64-bit and
incompatible).






> Python 2.4.4 builds fine using LTIB and runs on an iMX27 board.
> However, Python 2.4.4 is ancient and I need some features from a newer
> version.  I have been able to partially build Python 2.7.3 (the 2.7.3
> interpreter now runs on the iMX27 board), but I'm stuck building a few
> built-in modules like the _socket module (Modules/socketmodule.c).
>
> Here is what I've done so far:
>
>   * Grabbed the latest Python 2.7.3 source tarball from
> http://python.org/download/
>   * Grabbed an ARM cross-compile patch from
> http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html
>
>     /opt/ltib/pkgs/python-2.7.3-cross-compile.patch
>     /opt/ltib/pkgs/python-2.7.3-cross-compile.patch.md5
>     /opt/ltib/pkgs/Python-2.7.3.tar.bz2
>
>   * Modified the original 2.4.4 python.spec file from LTIB as follows:
>
>     $ cat dist/lfs-5.1/python/python.spec
>     %define pfx /opt/freescale/rootfs/%{_target_cpu}
>
>     Summary         : An interpreted object-oriented programming language.
>     Name            : python
>     Version         : 2.7.3
>     Release         : 1
>     License         : OSI Approved Python License
>     Vendor          : Freescale
>     Packager        : Stuart Hughes et al
>     Group           : Development/Languages
>     Source          : Python-%{version}.tar.bz2
>     Patch1              : Python-2.7.3-xcompile.patch
>     BuildRoot       : %{_tmppath}/%{name}
>     Prefix          : %{pfx}
>
>     %Description
>     %{summary}
>
>     %Prep
>     %setup -n Python-%{version}
>     %patch1 -p1
>
>     %Build
>     #
>     # Note: This cross compile method is adapted from:
>     #       http://www.ailis.de/~k/docs/crosscompiling/python.php
>     #
>     # build a version for the machine we are building on, before we
>     # build for the target
>     #
>
>     ORIG_PATH=$PATH
>     export PATH=$UNSPOOF_PATH
>     ./configure
>     make python Parser/pgen
>     mv python hostpython
>     mv Parser/pgen Parser/hostpgen
>
>     make distclean
>
>     export PATH=$ORIG_PATH
>
>     LDFLAGS="-L$DEV_IMAGE/usr/lib" \
>     ./configure --prefix=%{_prefix} --host=$CFGHOST --build=%{_build}
> --enable-shared --without-libdb --without-ssl
>
>     make HOSTPYTHON=./hostpython  HOSTPGEN=./Parser/hostpgen
> CROSS_COMPILE=yes
>
>     %Install
>     rm -rf $RPM_BUILD_ROOT
>     mkdir -p $RPM_BUILD_ROOT/%{pfx}/%{_prefix}
>     make prefix=$RPM_BUILD_ROOT/%{pfx}/%{_prefix} HOSTPYTHON=./hostpython
> \
>      CROSS_COMPILE=yes install
>
>     %Clean
>     rm -rf $RPM_BUILD_ROOT
>
>
>     %Files
>     %defattr(-,root,root)
>     %{pfx}/*
>
>
>   * Used LTIB to prepare and build Python 2.7.3:
>
>     $ ./ltib -m prep -p python
>     ...
>
>     $ ./ltib -m scbuild -p python
>     ...
>     ...
>     In file included from
> /home/ltib/rpm/BUILD/Python-2.7.3/Modules/socketmodule.c:178:
>     /usr/include/sys/param.h:75:1: warning: "MAX" redefined
>     /home/ltib/rpm/BUILD/Python-2.7.3/Modules/socketmodule.c:97:1:
> warning: this is the location of the previous definition
>     /home/ltib/rpm/BUILD/Python-2.7.3/Modules/socketmodule.c: In
> function 'socket_htons':
>     /home/ltib/rpm/BUILD/Python-2.7.3/Modules/socketmodule.c:3785:
> error: invalid 'asm': invalid operand for code 'w'
>     ...
>     ...
>     Failed to configure _ctypes module
>
>     Python build finished, but the necessary bits to build these
> modules were not found:
>     _tkinter           bsddb185           bz2
>     gdbm               readline           sunaudiodev
>     To find the necessary bits, look in setup.py in detect_modules()
> for the module's name.
>
>
>     Failed to build these modules:
>     _bsddb             _multiprocessing   _socket
>     _sqlite3           dbm                linuxaudiodev
>     ossaudiodev        select
>
>     + exit 0
>     Build time for python: 102 seconds
>
>
>
>
> The compiler warnings & errors above seem to be pointing to the fact
> that LTIB is still pointing to the x86 build host for some included
> files (/usr/include/sys, /usr/include/bits) during the second stage of
> cross-compilation :
>
>
> http://nerdland.net/unstumping-the-internet/invalid-operand-for-code-w/
>
> What else is needed to build the Python 2.7.3 socket module?  The
> Python 2.4.4 build successfully compiles the socket module under LTIB.
>  People have successfully compiled Python 2.7.3 for other ARM
> plarforms (e.g. Ubuntu 12.04 LTS for ARMv7 PandaBoard, Angstrom for
> ARMv7 BeagleBone, etc).
>
> I've also tried Mike Goins' patch below, but it did not work for core
> built-in Python modules like _socket:
>
>     http://lists.gnu.org/archive/html/ltib/2012-07/msg00034.html
>
> Thanks for any advice,
> Paul
>
> _______________________________________________
> LTIB home page: http://ltib.org
>
> Ltib mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/ltib

Attachment: ltib_host_python.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]