sl4a icon indicating copy to clipboard operation
sl4a copied to clipboard

Add scipy and numpy modules to standard modules

Open damonkohler opened this issue 9 years ago • 7 comments

From @GoogleCodeExporter on May 31, 2015 11:25

Is it possible to add numpy and scipy to the list of modules bundled with ASE.
They are not pure python modules and so cannot be added on the sd card.

Original issue reported on code.google.com by [email protected] on 23 Mar 2010 at 11:33

Copied from original issue: damonkohler/android-scripting#260

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

This would be amazing, if possible.

Original comment by [email protected] on 17 Jun 2010 at 7:23

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

With some plotting tool this would be killer!

Original comment by [email protected] on 13 Aug 2010 at 12:33

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

Matplotlib builds like a charm on my N900, should work on droid - so theres 
you're plotting tool.

Original comment by [email protected] on 13 Aug 2010 at 12:48

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

I've managed to get a build of NumPy on android, as described here 
http://groups.google.com/group/android-scripting/browse_thread/thread/2378edd0dc
5048fb/90156932d2fa20bc .  I've attached my patch, and here are the steps I had 
to take to get it to build and compile.

0) I built this on OSX Darwin, using the pre-built NDK r4, and I used 
android-8/arch-arm.

1) I'm still not sure how to get a new version of the Python tree on a 
non-emulator phone (I am new to this!) so I have not done so. However, it works 
fine on my emulator.  I'll try building an APK shortly and will update the 
issue with this info.

2) The attached patch modifies the NumPy sources (1.4.1) to allow LONG_DOUBLE 
to be undefined, to remove the usage of unittest, to remove the "newdoc" and to 
remove some of the changes to the build system to force linkages against 
accelerated LAPACK on OSX.  One could imagine 

3) I had to modify agcc a bit to get it to work with the pre-built Darwin 
toolchain in the NDK, but I assume this is par for the course. 

4) The NumPy compilation had to be modified substantially. 
   - CFLAGS had to pre-empt the linkage against the host Python's 
pyport.h, which meant adding in a -I/path/to/device/python2.6 
   - CC had to be set to be agcc. 
   - The build had to be done as "hostpython setup.py build --fcompiler=fake install --prefix=/path/to/host".  This should get piped into a log file. 
   - But, because it manually runs ranlib and links shared libraries, I had to additionally grep out the calls to gcc and to ranlib.  I re-did all the ranlib calls with arm-eabi-ranlib (this was for libnpymath.a), and then I re-ran the linkage with the same agcc arguments used for shared library linking in the Python Makefile: "-Xlinker -export-dynamic -shared" instead of (in my case on OSX) "-bundle -undefined dynamic_lookup". 
   - (This procedure is reminiscent of the full-static linkage done on Cray machines, where the solution is to usually just overwrite the build step in distutils.  I'm not sure if changing the toolchain for distutils is in the works for SL4A, but it might be neat.  For more info: http://yt.enzotools.org/wiki/CrayXT5Installation#Python ) 
   - the installation command didn't work, and would overwrite my libraries, so I manually copied them to the appropriate location in the python tree. 

5) I had to "adb push" the directory structure into the Python directory on the 
emulator, in 
/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/site- 
packages/ 

One thing I noticed was that without the "compiler" module installed .npz and 
.npy files, which are NumPy's mechanism for serializing arrays, were 
unavailable for use.  I'd personally really like to be able to pass data back 
and forth in this manner, so I re-enabled them.  But, perhaps flat binary is 
okay.

Original comment by [email protected] on 13 Aug 2010 at 3:00

Attachments:

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

Amazing work! This is great news. I cannot wait until this is integrated!

Original comment by [email protected] on 14 Aug 2010 at 5:29

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

why is there no progress in almost a year

Original comment by [email protected] on 5 Jun 2011 at 4:42

damonkohler avatar Jun 13 '15 20:06 damonkohler

From @GoogleCodeExporter on May 31, 2015 11:25

This should be moved over to http://code.google.com/p/python-for-android/
There are comprehensive instructions for building non-pure modules.

Original comment by rjmatthews62 on 6 Jun 2011 at 12:56

damonkohler avatar Jun 13 '15 20:06 damonkohler