ltib
[Top][All Lists]
Advanced

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

[Ltib] Building Python 2.7


From: Reiko
Subject: [Ltib] Building Python 2.7
Date: Mon, 29 Oct 2012 21:17:00 -0700

Hello,

Has anyone been able to build a recent Python version (e.g. 2.7) using LTIB?

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



reply via email to

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