[Python-Dev] Import Fails in setup.py On Android

Cyd Haselton chaselton at gmail.com
Tue Feb 3 12:37:18 CET 2015


Reply in body of email below for clarity

On February 2, 2015 4:09:20 PM CST, "Frank, Matthew I" <matthew.i.frank at intel.com> wrote:
>There’s now (as of a couple days ago) a python mobile-sig
>(https://mail.python.org/mailman/listinfo/mobile-sig).  While that
>group is much smaller than python-dev and probably not as knowledgeable
>about the Cpython source base, that’s where you’re going to find folks
>who have a vested interest in getting Python working on mobile
>platforms like Android.  (And who would be interested in hearing about
>your experiences, no matter whether they can help you or not.)
>

Thanks for the notification.  I'll definitely shoot them an email.

>What you are doing (trying to run the entire C compiler toolchain on an
>Android machine, instead of using the cross-compilers that come in
>Google’s Android NDK (native development kit)) is way outside the
>mainstream.  (I.e., you’re not going to find very many people trying to
>do this here or anywhere.)

There are several IDEs made for on-device compilation that include the GCC toolchain ported to the Android platform.

http://www.spartacusrex.com/terminalide.htm
http://kevinboone.net/kbox2_how_it_works.html

I use the latter of the two (but contribute binaries to the former) because of its focus on emulating a Linux filesystem in which to run software.

>
>Since you compiled all the libraries that you are linking against,
>there is some possibility (likelihood) that the problem is in one of
>those libraries, not anywhere in the CPython source.  (Some other
>library was compiled without the necessary –dl flag.)  The right way to
>track down this problem (no matter where it is) is to run under gdb and
>type “where” when the program crashes.
>

I did not compile all of the libraries that I'm linking against.  The GCC port I am using makes use of a sysroot, which contains the necessary  Android system libs and includes. 

The KBOX environment is built on a fakechroot that supports dynamic calls to Android's libc (and, I suspect, those functions that USUALLY reside in a normal libc...like dlopen) only.  Provided a build includes the correct -ldl -lc links, it will work in KBOX.

>The reason I suspect that the problem is in one of the libraries you
>compiled before building Python, rather than a problem in the CPython
>sources or build scripts, is that I don’t have this problem when I
>cross-compile Python 3.4.2 on a Linux machine, then take the result and
>copy it over to the Android machine.  I’ve posted instructions and
>patches for successfully performing this cross compilation (for Android
>KitKat running on an x86) here:
>https://github.com/wandering-logic/android_x86_python-3.4.
>

See answer above.  I'm working in an environment on the Android device.  

Hopefully this clarifies things.  I'll re-post this over at python-sig.

>Best,
>-Matt
>
>From: Cyd Haselton [mailto:chaselton at gmail.com]
>Sent: Monday, February 02, 2015 3:25 PM
>To: Ryan Gonzalez
>Cc: Python-Dev
>Subject: Re: [Python-Dev] Import Fails in setup.py On Android
>
>No traceback unfortunately...the fakechroot in the environment throws
>the error and setup.py<http://setup.py> fails.
>
>I'll roll back that change...any idea where I could find info about the
>original method?
>On February 2, 2015 3:17:54 PM CST, Ryan Gonzalez
><rymg19 at gmail.com<mailto:rymg19 at gmail.com>> wrote:
>In reality, things just got broken even more. I don't know when that
>patch was created, but it's now very out of date: importlib._bootstrap
>has no load function. That's what the error you're getting is telling
>you. Since it isn't getting to load anything, the issue seems "solved".
>Not really.
>
>What's the full traceback for the undefined reference exception?
>
>On Mon, Feb 2, 2015 at 2:04 PM, Cyd Haselton
><chaselton at gmail.com<mailto:chaselton at gmail.com>> wrote:
>Update: While waiting for replies I made the change referenced here:
>https://bugs.python.org/review/5309/diff2/12811:12826/setup.py?context=3&column_width=80
>
>specifically changing
>importlib. _bootstrap._SpecMethods(spec).load()
>to
>importlib._bootstrap.load(spec)
>
>I no longer get a terminating 'undefined reference to dlopen' error,
>but I do get 'importing extensions failed' errors for each
>extension...like this:
>
>*** WARNING: importing extension "_pickle" failed with <class
>'AttributeError'>: 'module' object has no attribute 'load'
>
>On February 2, 2015 1:36:29 PM CST, Cyd Haselton
><chaselton at gmail.com<mailto:chaselton at gmail.com>> wrote:
>After fixing a segfault issue (many thanks Ryan) I'm back to the same
>issue I was having with Python 2.7.8; the newly built python throws an
>undefined reference to dlopen when running
>setup.py<http://setup.py>...specifically when importing just-built
>extensions
>
>I've managed to narrow the problem down to the following line:
>
>importlib._bootstrap._SpecMethods(spec).load()
>
>Googling this brings up a few hits from
>bugs.python.org<http://bugs.python.org> and not much else. I'm new to
>Python; any ideas what this does...or where I can read up on it for
>troubleshooting purposes?
>
>--
>Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
>_______________________________________________
>Python-Dev mailing list
>Python-Dev at python.org<mailto:Python-Dev at python.org>
>https://mail.python.org/mailman/listinfo/python-dev
>Unsubscribe:
>https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com
>
>
>
>--
>Ryan
>If anybody ever asks me why I prefer C++ to C, my answer will be
>simple: "It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think
>that was nul-terminated."
>Personal reality distortion fields are immune to contradictory
>evidence. - srean
>Check out my website: http://kirbyfan64.github.io/
>
>--
>Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the Python-Dev mailing list