recipes depending on external modules

121 views
Skip to first unread message

Przemysław Szulczyński

unread,
Jun 4, 2013, 3:19:09 PM6/4/13
to python-...@googlegroups.com
Hi there,

I have been struggling for some time to add matplotlib recipe to python-for-android project and now since numpy was recently added I hoped it will be easier but I am stuck with importing a dependency lib (numpy)
I downloaded matplotlib source code and when trying to import numpy I get an 'cannot open shared object file: No such file or directory' error:

============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.1.1
                python: 2.7.2 (default, Jun  3 2013, 23:16:27)  [GCC 4.6.3]
              platform: linux3

REQUIRED DEPENDENCIES
['/home/przemek/python-for-android/build/matplotlib/matplotlib-1.1.1', '/home/przemek/python-for-android/build/python-install/lib/python27.zip', '/home/przemek/python-for-android/build/python-install/lib/python2.7', '/home/przemek/python-for-android/build/python-install/lib/python2.7/plat-linux3', '/home/przemek/python-for-android/build/python-install/lib/python2.7/lib-tk', '/home/przemek/python-for-android/build/python-install/lib/python2.7/lib-old', '/home/przemek/python-for-android/build/python-install/lib/python2.7/lib-dynload', '/home/przemek/python-for-android/build/python-install/lib/python2.7/site-packages']
/home/przemek/python-for-android/build/python-install/lib/python2.7/site-packages/numpy/core/multiarray.so: cannot open shared object file: No such file or directory
                 numpy: no
                        * You must install numpy 1.4 or later to build
                        * matplotlib.


I suppose that this is because numpy so is ARM compiled and python.host binary cannot access it since it is compiled for another architecture

/home/przemek/python-for-android/build/numpy/numpy-1.7.1/build/lib.linux-i686-2.7/numpy/core/multiarray.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamical
ly linked, not stripped


my recipe.sh is cloned from numpy and looks so far like this:

#!/bin/bash

VERSION_matplotlib=1.1.1
URL_matplotlib=http://pypi.python.org/packages/source/m/matplotlib/matplotlib-${VERSION_matplotlib}.tar.gz
DEPS_matplotlib=(numpy)
MD5_matplotlib=30ee59119599331bf1f3b6e838fee9a8
BUILD_matplotlib=$BUILD_PATH/matplotlib/$(get_directory $URL_matplotlib)
RECIPE_matplotlib=$RECIPES_PATH/matplotlib
       
function prebuild_matplotlib() {
        cd $BUILD_matplotlib
               
        if [ -f .patched ]; then
                return
        fi
 
        try patch -p1 < $RECIPE_matplotlib/patches/fix-matplotlib.patch
        touch .patched
}

function build_matplotlib() {

        if [ -d "$BUILD_PATH/python-install/lib/python2.7/site-packages/matplotlib" ]; then
                return
        fi

        cd $BUILD_matplotlib
  env
  echo "push_arm"

        push_arm
  env
  #PATH=$PATH:/home/przemek/python-for-android/build/python-install/lib/python2.7

  #export PATH=$PATH:$BUILD_PATH/numpy/numpy-1.7.1/build/lib.linux-i686-2.7
  try $BUILD_PATH/python-install/bin/python.host setup.py build_ext -v
       
        try find build/lib.* -name "*.o" -exec $STRIP {} \;
        try $BUILD_PATH/python-install/bin/python.host setup.py install -O2

        pop_arm
}

function postbuild_matplotlib() {
        true
}


I noticed that https://play.google.com/store/apps/details?id=org.thinktanks.mathsysalpha&hl=en already uses kivy + matlplotlib, therefore there has to be a way to setup this

any help/clue is greatly appreciated


Przemysław Szulczyński

unread,
Jun 6, 2013, 3:43:41 AM6/6/13
to python-...@googlegroups.com
I am getting closer - I managed to compile & build matplotlib for arm using LXC and made kivy based apk using this, perhaps this is the way to go?

I/python  ( 5724):    File "/scratch/pyth/xtest/main.py", line 19, in <module>
I/python  ( 5724): [2013-06-06 09:36:20,967][WARNING][write] stderr:   File "/scratch/pyth/xtest/main.py", line 19, in <module>
I/python  ( 5724):    File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/pyplot.py", line 26, in <module>
I/python  ( 5724): [2013-06-06 09:36:20,972][WARNING][write] stderr:   File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/pyplot.py", line 26, in <module>
I/python  ( 5724):    File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/figure.py", line 24, in <module>
I/python  ( 5724): [2013-06-06 09:36:20,976][WARNING][write] stderr:   File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/figure.py", line 24, in <module>
I/python  ( 5724):    File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/artist.py", line 7, in <module>
I/python  ( 5724): [2013-06-06 09:36:20,984][WARNING][write] stderr:   File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/artist.py", line 7, in <module>
I/python  ( 5724):    File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
I/python  ( 5724): [2013-06-06 09:36:20,996][WARNING][write] stderr:   File "/scratch/pyth/python-for-android/dist/default/private/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
I/python  ( 5724):  ImportError: Cannot load library: link_image[1936]:   101 could not load needed library 'libstdc++.so.6' for '_path.so' (load_library[1091]: Library 'libstdc++.so.6' not found)
I/python  ( 5724): [2013-06-06 09:36:21,001][WARNING][write] stderr: ImportError: Cannot load library: link_image[1936]:   101 could not load needed library 'libstdc++.so.6' for '_path.so' (load_library[1091]: Library 'libstdc++.so.6' not found)

There is still one problem though, _path.so (and others I guess) has dependency on libstdc++.so.6 and it cannot load one even if I copied it to the same folder. Maybe it should be statically linked?

Paul Royik

unread,
Dec 10, 2015, 3:59:01 AM12/10/15
to Python For Android
Hello.
Did you manage to run matplotlib?
I'm struggling with the same problem: including numpy as dependency.
Reply all
Reply to author
Forward
0 new messages