Friday, May 31, 2013

py4a site-packages revisited without root

Adding pure-python packages is a snap.
  1. add the following file
    import site
    SITEPKGS = "/mnt/sdcard/com.googlecode.pythonforandroid/extras/python/site-packages"
    site.addsitedir(SITEPKGS)

    saved as
    sitecustomize.py
    to your py4a folder, probably
    /mnt/sdcard/com.googlecode.pythonforandroid/extras/python/
    although you may find your external (or internal) storage at either
    /storage/sdcard0 or /storage/sdcard1change the SITEPKGS external storage mount too!
    This file should add your site-packages folder to your python path. test it by running the interpreter, import sys, and checking sys.path. do you see it now?
  2. download the source tarball
  3. untar the source
  4. find the folder that contains the package you want to import and copy it to your site-packages folder
  5. try to import it and then try to use it. does it work?
I've done this successfully with both dulwich, which has pure python versions of all C extensions, and paramiko which requires pycrypto which you can download and install via py4a.

No comments:

Post a Comment

Fork me on GitHub