Difference between revisions of "Python"

From CBLFS
Jump to navigationJump to search
(I add a flag to make in the instructions so that make test and make install succeed.)
Line 28: Line 28:
  
 
  '''Note:'''
 
  '''Note:'''
  It appears that if you want to run the test suites ('''make test'''),
+
  If the test suite ('''make test''') fails because it cannot find
  you need to install the package first, otherwise it is unable to
+
  python's math library, then you will need to install python before
  locate the appropriate python modules to run the tests.
+
you can run the tests.
 +
 
 +
'''Note:'''
 +
If the installation of python fails, try again few times. It appears
 +
to be somewhat inconsistant with regards to whether it works or not.
 +
The ''-fwrapv'' flag used with make mostly fixes this. If it still
 +
doesn't complete '''make install''' without failing, then use
 +
'''make -i install''' instead ('''-i''' tells '''make''' to ignore errors).
 +
  It's less desirable, but it should work.
  
  
Line 37: Line 45:
 
  patch -Np1 -i ../Python-{{Python-Version}}-gdbm-1.patch &&
 
  patch -Np1 -i ../Python-{{Python-Version}}-gdbm-1.patch &&
 
  ./configure --prefix=/usr --enable-shared &&
 
  ./configure --prefix=/usr --enable-shared &&
  make
+
  make EXTRA_CFLAGS="-fwrapv"
  
 
Install the package
 
Install the package
  
 
  make install
 
  make install
 +
 +
=== Command Explanations ===
 +
 +
''--enable-shared'': Enables the building of shared libraries.
 +
 +
''-fwrapv'': This flag is used to make it so that '''make test''' can find the python libraries and so that '''make install''' doesn't fail. Why this fixes the problem is unknown. According to GCC, ''-fwrapv'' "instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation."
  
 
== Multilib ==
 
== Multilib ==
Line 52: Line 66:
 
  CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" ./configure --prefix=/usr \
 
  CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" ./configure --prefix=/usr \
 
     --enable-shared &&
 
     --enable-shared &&
  make
+
  make EXTRA_CFLAGS="-fwrapv"
  
 
Install the package
 
Install the package
Line 80: Line 94:
 
  CC="gcc ${BUILDN32}" CXX="g++ ${BUILDN32}" ./configure --prefix=/usr \
 
  CC="gcc ${BUILDN32}" CXX="g++ ${BUILDN32}" ./configure --prefix=/usr \
 
     --libdir=/usr/lib32 --enable-shared &&
 
     --libdir=/usr/lib32 --enable-shared &&
  make
+
  make EXTRA_CFLAGS="-fwrapv"
  
 
Install the package
 
Install the package
Line 108: Line 122:
 
  CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" ./configure --prefix=/usr \
 
  CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" ./configure --prefix=/usr \
 
     --libdir=/usr/lib64 --enable-shared &&
 
     --libdir=/usr/lib64 --enable-shared &&
  make
+
  make EXTRA_CFLAGS="-fwrapv"
  
 
Install the package
 
Install the package

Revision as of 14:03, 1 January 2007

Download Source: http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.bz2
Required Patch: http://svn.cross-lfs.org/svn/repos/patches/Python/Python-2.7.8-gdbm-1.patch
Required Patch (For Multilib): http://svn.cross-lfs.org/svn/repos/patches/Python/Python-2.7.8-multilib-1.patch

Introduction to Python

The Python package contains the Python development environment. This is useful for object-oriented programming, writing scripts, prototyping large programs or developing entire applications.

Dependencies

Optional

Non-Multilib

Note:
If the test suite (make test) fails because it cannot find
python's math library, then you will need to install python before
you can run the tests.
Note:
If the installation of python fails, try again few times. It appears
to be somewhat inconsistant with regards to whether it works or not.
The -fwrapv flag used with make mostly fixes this. If it still
doesn't complete make install without failing, then use
make -i install instead (-i tells make to ignore errors).
It's less desirable, but it should work.


Compile the package:

patch -Np1 -i ../Python-2.7.8-gdbm-1.patch &&
./configure --prefix=/usr --enable-shared &&
make EXTRA_CFLAGS="-fwrapv"

Install the package

make install

Command Explanations

--enable-shared: Enables the building of shared libraries.

-fwrapv: This flag is used to make it so that make test can find the python libraries and so that make install doesn't fail. Why this fixes the problem is unknown. According to GCC, -fwrapv "instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation."

Multilib

32Bit

Compile the package:

patch -Np1 -i ../Python-2.7.8-gdbm-1.patch &&
CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" ./configure --prefix=/usr \
    --enable-shared &&
make EXTRA_CFLAGS="-fwrapv"

Install the package

make install &&
mv -v /usr/bin/python{,-32} &&
mv -v /usr/bin/python2.7.8{,-32} &&
mv -v /usr/include/python2.7.8/pyconfig{,-32}.h

N32

Change the libdir that Python is going to use to lib32:

patch -Np1 -i ../Python-2.7.8-multilib-1.patch
sed -i -e "s:@@MULTILIB_DIR@@:lib32:g" \
        Lib/distutils/command/install.py \
        Lib/distutils/sysconfig.py \
        Lib/site.py \
        Makefile.pre.in \
        Modules/Setup.dist \
        Modules/getpath.c \
        setup.py

Compile the package:

patch -Np1 -i ../Python-2.7.8-gdbm-1.patch &&
CC="gcc ${BUILDN32}" CXX="g++ ${BUILDN32}" ./configure --prefix=/usr \
    --libdir=/usr/lib32 --enable-shared &&
make EXTRA_CFLAGS="-fwrapv"

Install the package

make install &&
mv -v /usr/bin/python{,-n32} &&
mv -v /usr/bin/python2.7.8{,-n32} &&
mv -v /usr/include/python2.7.8/pyconfig{,-n32}.h

64Bit

Change the libdir that Python is going to use to lib64:

patch -Np1 -i ../Python-2.7.8-multilib-1.patch
sed -i -e "s:@@MULTILIB_DIR@@:lib64:g" \
        Lib/distutils/command/install.py \
        Lib/distutils/sysconfig.py \
        Lib/site.py \
        Makefile.pre.in \
        Modules/Setup.dist \
        Modules/getpath.c \
        setup.py

Compile the package:

patch -Np1 -i ../Python-2.7.8-gdbm-1.patch &&
CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" ./configure --prefix=/usr \
    --libdir=/usr/lib64 --enable-shared &&
make EXTRA_CFLAGS="-fwrapv"

Install the package

make install &&
mv -v /usr/bin/python{,-64} &&
mv -v /usr/bin/python2.7.8{,-64} &&
ln -sfv multiarch_wrapper /usr/bin/python &&
ln -sfv multiarch_wrapper /usr/bin/python2.4 &&
mv -v /usr/include/python2.7.8/pyconfig{,-64}.h

Creating a Stub Header (Multilib Only)

Creating a Generic Stub Header

cat > /usr/include/python2.7.8/pyconfig.h.h << "EOF"
/* pyconfig.h.h - Stub Header  */
#ifndef __STUB__PYCONFIG.H_H__
#define __STUB__PYCONFIG.H_H__

#if defined(__x86_64__) || \
    defined(__sparc64__) || \
    defined(__arch64__) || \
    defined(__powerpc64__) || \
    defined (__s390x__)
# include "pyconfig.h-64.h"
#else
# include "pyconfig.h-32.h"
#endif

#endif /* __STUB__PYCONFIG.H_H__ */
EOF

Creating a Stub Header For Mips

cat > /usr/include/python2.7.8/pyconfig.h.h << "EOF"
/* pyconfig.h.h - Stub Header  */
#ifndef __STUB__PYCONFIG.H_H__
#define __STUB__PYCONFIG.H_H__

#include <sgidefs.h>

#if (_MIPS_SIM == _ABIO32)
# include "pyconfig.h-32.h"
#elif (_MIPS_SIM == _ABIN32)
# include "pyconfig.h-n32.h"
#elif (_MIPS_SIM == _ABI64)
# include "pyconfig.h-64.h"
#endif

#endif /* __STUB__PYCONFIG.H_H__ */
EOF