[pyar] Problemas compilando Python 3 estáticamente

hipersayan x hipersayan.x en gmail.com
Mie Ago 18 14:00:50 ART 2010


Hola, que tal? estoy intentando compilar python 3 de forma estática
bajo linux, para poder crear un python portable que funcione bajo
cualquier distro. El problema es que al momento de compilar me genera
bibliotecas corruptas(las *.so), todas ellas finalizan con
*_failed.so, si les cambio el nombre me dan errores al ejecutarlas.
Este es el script que estoy usando:

#! /bin/bash
# -- BEGIN SCRIPT --

python_version='3.1.2'
python_folder="Python-$python_version"
python_tar_bz2="$python_folder.tar.bz2"

# Lo descargo de la pagina.
wget --retry-connrefused -c
http://www.python.org/ftp/python/$python_version/$python_tar_bz2
tar -xjvf $python_tar_bz2
cd $python_folder

# Le agrego las flags necesarias para volverlo estatico.
./configure LDFLAGS='-static -static-libgcc' CPPFLAGS='-static'
make
cd ..

# Copio el binario, todos los modulos y bibliotecas dinamicas a la
carpeta donde se va a ejecutar todo.
mkdir -p python/bin python/doc python/lib
cp $python_folder/python python/bin
cp $python_folder/README python/doc
cp $python_folder/LICENSE python/doc

base_dir=$(pwd)

cd $python_folder/Lib
find . -name '*.py' -exec cp -v --parents {} $base_dir/python/lib/ \;
din_libs_dir=$base_dir/$python_folder/build/$(ls
$base_dir/$python_folder/build|grep lib.)
cd $din_libs_dir

for filename in $(ls .)
do
    cp -vT $filename "$base_dir/python/lib/$(echo $filename|sed 's/_failed//g')"
done

cd $base_dir/$python_folder
make clean
cd $base_dir

# Creo el script necesario para lanzar el python portable.
echo '#! /bin/bash'>python/python.sh
echo ''>>python/python.sh
echo 'export PYTHONPATH=./lib'>>python/python.sh
echo 'export PYTHONHOME=./lib'>>python/python.sh
echo './bin/python -B'>>python/python.sh

chmod 777 python/python.sh
# -- END SCRIPT --

Luego de esto, llamo a python con ./python.sh, escribo help(), y este
es el error que me da:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./lib/site.py", line 428, in __call__
    import pydoc
  File "/home/hipersayan_x/tmp/MyPython/python/lib/pydoc.py", line 55,
in <module>
    import sys, imp, os, re, inspect, builtins, pkgutil
  File "/home/hipersayan_x/tmp/MyPython/python/lib/inspect.py", line
42, in <module>
    from operator import attrgetter
ImportError: /home/hipersayan_x/tmp/MyPython/python/lib/operator.so:
undefined symbol: PyExc_TypeError

Alguna idea de como puedo compilar python estáticamente y que funcione?



More information about the pyar mailing list