chrippa / python-librtmp

python-librtmp is a RTMP client library. It uses the implementation provided by librtmp via cffi.
BSD 2-Clause "Simplified" License
154 stars 33 forks source link

Cross compile python-librtmp #3

Open athoik opened 10 years ago

athoik commented 10 years ago

Hello,

Is there any guide how to crosscompile python-librtmp?

The most interesting architechures is mipsel (and arm).

Thanks

chrippa commented 10 years ago

I haven't tried myself, but it shouldn't be any different from cross compiling any other Python extension.

athoik commented 10 years ago

Actually i tried building python-librtmp using Openembedded, but i an getting error about cffi.

ERROR: Function failed: do_compile (log file is located at /opt/openpli4/build/tmp/work/mips32el-oe-linux/python-librtmp/0.1.2-r0/temp/log.do_compile.19056)
ERROR: Logfile of failure stored in: /opt/openpli4/build/tmp/work/mips32el-oe-linux/python-librtmp/0.1.2-r0/temp/log.do_compile.19056
Log data follows:
| DEBUG: Executing shell function do_compile
| Error: CFFI (required for setup) is not available.
| Please use 'pip install cffi', or equivalent.
| ERROR: python setup.py build_ext execution failed.
| ERROR: Function failed: do_compile (log file is located at /opt/openpli4/build/tmp/work/mips32el-oe-linux/python-librtmp/0.1.2-r0/temp/log.do_compile.19056)
ERROR: Task 6 (/opt/openpli4/meta-local/recipes-local/python/python-librtmp_0.1.2.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1199 tasks of which 1193 didn't need to be rerun and 1 failed.
No currently running tasks (1199 of 1208)

Summary: 1 task failed:
  /opt/openpli4/meta-local/recipes-local/python/python-librtmp_0.1.2.bb, do_compile
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

I was able to build sucessfully depents (pycparser, cffi, etc)

pycparser_2.10.bb

DESCRIPTION = "C parser in Python"
HOMEPAGE = "https://github.com/eliben/pycparser"
SECTION = "devel/python"

DEPENDS = "python-core"

LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=d29d3ce07825100c58ca57eea171ab65"
PR = "r0"

SRC_URI = "https://pypi.python.org/packages/source/p/pycparser/pycparser-${PV}.tar.gz"
SRC_URI[md5sum] = "d87aed98c8a9f386aa56d365fe4d515f"
SRC_URI[sha256sum] = "957d98b661c0b64b580ab6f94b125e09b6714154ee51de40bca16d3f0076b86c"

S = "${WORKDIR}/pycparser-${PV}"

inherit distutils

cffi_0.8.bb

DESCRIPTION = "Foreign Function Interface for Python calling C code."
HOMEPAGE = "http://cffi.readthedocs.org"
SECTION = "devel/python"

DEPENDS = " \
    python-core \
    libffi \
"

RDEPENDS_${PN} = "pycparser"

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=5677e2fdbf7cdda61d6dd2b57df547bf"
PR = "r0"

SRC_URI = "https://pypi.python.org/packages/source/c/cffi/cffi-${PV}.tar.gz"
SRC_URI[md5sum] = "e61deb0515311bb42d5d58b9403bc923"
SRC_URI[sha256sum] = "c336ee26831ac9da2c0ed0ea094941d2fc5877c3468e7ee703047c571180dde3"

S = "${WORKDIR}/cffi-${PV}"

inherit setuptools

python-librtmp_0.1.2.bb

DESCRIPTION = "Python bindings for librtmp, built with cffi"
HOMEPAGE = "https://github.com/chrippa/python-librtmp"
SECTION = "devel/python"

DEPENDS = " \
    python-core \
    librtmp \
    cffi \
"

LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=6364c4dd2cab9d13505f6489d238eb2a"
PR = "r0"

SRC_URI = "https://pypi.python.org/packages/source/p/python-librtmp/python-librtmp-${PV}.tar.gz"
SRC_URI[md5sum] = "2a1d37dc84f09a5c5a99bc435029c733"
SRC_URI[sha256sum] = "207e539c04419cc2ea3380cfdee0c8576168079603168c7cc1807e9f4982e997"

S = "${WORKDIR}/python-librtmp-${PV}"

inherit setuptools
#inherit distutils

If someone has an idea how to bypass above problem, please share.

athoik commented 10 years ago

Hello again,

I tried to build the python-librtmp using Openembedded devshell (devshell setups all required environment variables for cross compile) and now the error is diffrent.

$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/librtmp
copying librtmp/logging.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/aval.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/rtmp.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/compat.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/utils.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/exceptions.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/__init__.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/stream.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/amf.py -> build/lib.linux-x86_64-2.7/librtmp
copying librtmp/packet.py -> build/lib.linux-x86_64-2.7/librtmp
creating build/lib.linux-x86_64-2.7/librtmp_config
copying librtmp_config/__init__.py -> build/lib.linux-x86_64-2.7/librtmp_config
creating build/lib.linux-x86_64-2.7/librtmp_ffi
copying librtmp_ffi/__init__.py -> build/lib.linux-x86_64-2.7/librtmp_ffi
copying librtmp_ffi/verifier.py -> build/lib.linux-x86_64-2.7/librtmp_ffi
copying librtmp_ffi/binding.py -> build/lib.linux-x86_64-2.7/librtmp_ffi
copying librtmp_ffi/ffi.py -> build/lib.linux-x86_64-2.7/librtmp_ffi
running build_ext
building '_binding' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/librtmp_ffi
creating build/temp.linux-x86_64-2.7/librtmp_ffi/__pycache__
creating build/temp.linux-x86_64-2.7/src
creating build/temp.linux-x86_64-2.7/src/librtmp
mipsel-oe-linux-gcc -mel -mabi=32 -mhard-float -march=mips32 --sysroot=/opt/openpli/build/tmp/sysroots/dm800se -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -O2 -pipe -g -feliminate-unused-debug-types -fPIC -I/usr/include/python2.7 -c librtmp_ffi/__pycache__/_binding.c -o build/temp.linux-x86_64-2.7/librtmp_ffi/__pycache__/_binding.o
cc1: warning: include location "/usr/include/python2.7" is unsafe for cross-compilation [-Wpoison-system-directories]
In file included from /usr/include/python2.7/Python.h:58:0,
                 from librtmp_ffi/__pycache__/_binding.c:2:
/usr/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
  ^
error: command 'mipsel-oe-linux-gcc' failed with exit status 1

Any idea?

(i think it mixes host with target...)

athoik commented 10 years ago

Hello,

Since i couldn't cross compile python-librtmp, i took different approach.

Install qemu

(Instractions from here http://rkpisanu.altervista.org/doku.php?id=qemu:qemu_post_install)

# Download kernel and initrd
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-mipsel/current/images/malta/netboot/vmlinux-3.2.0-4-4kc-malta
wget http://ftp.nl.debian.org/debian/dists/stable/main/installer-mipsel/current/images/malta/netboot/initrd.gz

# Create virtual disk
qemu-img create debian_mipsel.img 2G

# Install
qemu-system-mipsel -M malta -hda debian_mipsel.img -m 256 -kernel vmlinux-3.2.0-4-4kc-malta -initrd initrd.gz -append "root=/dev/sda1 console=tty0"

# Run
qemu-system-mipsel -M malta -hda debian_mipsel.img -m 256 -kernel vmlinux-3.2.0-4-4kc-malta -append "root=/dev/sda1 console=tty0"

After installation completed, first i installed the following:

apt-get install python-pip build-essential librtmp-dev libffi-dev -y 

Then i tried to install cffi but the following error occured:

pip install cffi

pip_install_cffi_missing_headers

In order to solved it we need to install also python-dev

apt-get install python-dev -y

Then cffi installed and python-librtmp also.

pip install python-librtmp

pip_install_python-librtmp

So my next step is to pack compiled files and python files and see if it works :)

Necktwi commented 5 years ago

I am facing a similar #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." issue while building pyblake2-1.1.2. Any solution without chroot?