Godiyos / python-for-android

Automatically exported from code.google.com/p/python-for-android
Apache License 2.0
0 stars 0 forks source link

Problem on Building Modules #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to building the "requests" python module for the android platform 
(create new egg file).

I followed this instructions:

http://code.google.com/p/python-for-android/wiki/BuildingModules

Note: I am making the bellow steps on the ubuntu 64 machine.

Step 1) Download python-lib_r16.zip and extract it to 
/home/victor/Desktop/python

Step 2) Download the NDK for Android - 
http://dl.google.com/android/ndk/android-ndk-r8-linux-x86.tar.bz2 and extract 
it to /home/victor/Desktop/python

Step 3) Run this:
export ANDROID_NDK=~/android-ndk-r5
export ANDROID_NDK_TOOLCHAIN_ROOT=~/android-toolchain
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 
--install-dir=$ANDROID_NDK_TOOLCHAIN_ROOT

Step 4) Download the requests module:
git clone git://github.com/kennethreitz/requests.git

Step 5) Edit the setup.py file, adding the two lines:
from py4a import patch_distutils
patch_distutils()

Step 6) Create a new file setup.cfg:
[bdist_egg]
plat-name=linux-armv

Step 7) cd /home/victor/Desktop/python/requests
python2.6 setup.py bdist_egg

And this is the result:
Traceback (most recent call last):
  File "setup.py", line 13, in <module>
    from py4a import patch_distutils
ImportError: No module named py4a

How can i compile the module with successfully ?

I don't understood this step on documentation:
Unzip this into python-modules/python-lib
Question: What folder is it on ubuntu ? 
/usr/lib/python2.6/dist-packages

Thanks,

Victor Jabur

Original issue reported on code.google.com by victorja...@gmail.com on 29 May 2012 at 4:33

GoogleCodeExporter commented 9 years ago
I run the source ~python-lib_r16/python.sh and tried to build the module again:

victor@victor-desktop:~/Desktop/python/requests$ python2.6 setup.py bdist_egg
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    import requests
  File "/home/victor/Desktop/python/requests/requests/__init__.py", line 25, in <module>
    from . import utils
  File "/home/victor/Desktop/python/requests/requests/utils.py", line 19, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/home/victor/Desktop/python/requests/requests/compat.py", line 85, in <module>
    import cookielib
  File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/cookielib.py", line 38, in <module>
  File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/calendar.py", line 9, in <module>
ImportError: 
/home/victor/Desktop/python/com.googlecode.pythonforandroid/files/python/lib/pyt
hon2.6/lib-dynload/datetime.so: wrong ELF class: ELFCLASS32

Original comment by victorja...@gmail.com on 29 May 2012 at 4:54

GoogleCodeExporter commented 9 years ago
Where is the python binary referenced inside the python.sh file ?

/data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"

The binary doesn't exists

Original comment by victorja...@gmail.com on 29 May 2012 at 4:55

GoogleCodeExporter commented 9 years ago
Another error calling binary python:

victor@victor-desktop:~/Desktop/python/requests$ python
ImportError: Bad magic number in 
/home/victor/Desktop/python/com.googlecode.pythonforandroid/extras/python/site.p
yc

Original comment by victorja...@gmail.com on 29 May 2012 at 4:57

GoogleCodeExporter commented 9 years ago
requests is pure python. I was able to install it by just copying the extracted 
folder to the site-packages folder in 
/mnt/sdcard/com.googlecode.pythonforandroid/extras/python/ and then adding 
site-packages to the pythonpath either using the standalone shell script or by 
importing sys and running 
sys.path.append('/mnt/sdcard/com.googlecode.pythonforandroid/extras/python/site-
packages'). This worked for every module I imported: requests, rpdb (remote 
debugging) and dulwich (pure git wrapper).

Another option is to install distribute, which works well with the standalone 
shell script, but may have issues in the sl4a interpreter.

http://poquitopicante.blogspot.com/2013/01/distributesetuptools-for-py4a.html

Original comment by bwanama...@gmail.com on 8 Jan 2013 at 7:34

GoogleCodeExporter commented 9 years ago
You need to install python-lib first and extract it then add module source code 
on top of that. I have created a script you can use to generate modules from 
git reops: https://cs.uwaterloo.ca/~hmohajer/module-creator.sh

Original comment by hooma...@gmail.com on 1 Mar 2014 at 9:54