0

I compiled some python modules (which contains some shared libraries) for android. since android mounts sdcard with noexec option, I am forced to put whole python package (ie, *.py + *.so files) in /data partition or any ware in phone memory

since phone memory is very limited, I need a way to keep only shared libraries in /data partion and all *.py files in /sdcard for a single python package.

for example, for numpy package i wish I could put

"numpy.core.multiarray.so" in /data/local/lib/python27/

&

whole numpy package tree (excluding shared libraries) in /sdcard/python/

(sys.path contains both '/sdcard/python/' & '/data/local/lib/python27/')

Any one help please....

harish2704
  • 591
  • 6
  • 16
  • sys.path should help you, just append you path to the list - [sys.path](http://docs.python.org/2/library/sys.html#sys.path) – PurityLake Mar 08 '13 at 19:35

2 Answers2

2

All you need to do is to add the directory to the PATH, using sys.path. So for your case, it'd look like

import sys.path
sys.path.append(r'/data/local/lib/python27/')
TankorSmash
  • 12,186
  • 6
  • 68
  • 106
  • I think I need to calrify my question. my question is 'Does python allow us to put files from a single package to different locations??' – harish2704 Mar 10 '13 at 06:19
  • @harish2704 So long as the package is told where all its files are, I don't see why not. Best to ask someone else who could give you a definitive answer. – TankorSmash Mar 10 '13 at 07:12
1

Modifying the __path__ variable in the __init__ file of the package is the solution. For more detail, see What is path useful for?

Community
  • 1
  • 1
harish2704
  • 591
  • 6
  • 16