OpenWrt Forum Archive

Topic: trying to build numpy package.

The content of this topic has been archived on 10 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am trying to build numpy package. pevious one is outdated and broke.
so i've had some initial work. but lead error

Makefile

#
# Copyright (C) 2008-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=numpy
PKG_VERSION:=1.6.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/
PKG_MD5SUM:=2bce18c08fc4fce461656f0f4dd9103e

include $(INCLUDE_DIR)/package.mk
$(call include_mk, python-package.mk)

define Package/numpy
  SUBMENU:=Python
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=numpy
  URL:=http://numpy.sf.net
  DEPENDS:=+python-mini
endef

define Package/numpy/description
  Numpy
endef

define Build/Compile
        $(if $(Build/Compile/PyMod),,@echo Python packaging code not found.; false)
        $(call Build/Compile/PyMod,., \
                build , \
                BASECFLAGS="$(TARGET_CFLAGS)" \
        )
endef

define Package/numpy/install
        $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
        $(CP) \
                $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
                $(1)$(PYTHON_PKG_DIR)
endef

$(eval $(call PyPackage,numpy))
$(eval $(call BuildPackage,numpy))

fenv patch

error message

creating build/lib.linux-i686-2.6/numpy/matrixlib
copying numpy/matrixlib/setupscons.py -> build/lib.linux-i686-2.6/numpy/matrixlib
copying numpy/matrixlib/defmatrix.py -> build/lib.linux-i686-2.6/numpy/matrixlib
copying numpy/matrixlib/setup.py -> build/lib.linux-i686-2.6/numpy/matrixlib
copying numpy/matrixlib/__init__.py -> build/lib.linux-i686-2.6/numpy/matrixlib
creating build/lib.linux-i686-2.6/numpy/compat
copying numpy/compat/setupscons.py -> build/lib.linux-i686-2.6/numpy/compat
copying numpy/compat/py3k.py -> build/lib.linux-i686-2.6/numpy/compat
copying numpy/compat/setup.py -> build/lib.linux-i686-2.6/numpy/compat
copying numpy/compat/_inspect.py -> build/lib.linux-i686-2.6/numpy/compat
copying numpy/compat/__init__.py -> build/lib.linux-i686-2.6/numpy/compat
creating build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/hermite.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/polynomial.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/chebyshev.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/setup.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/laguerre.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/polyutils.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/__init__.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/polytemplate.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/hermite_e.py -> build/lib.linux-i686-2.6/numpy/polynomial
copying numpy/polynomial/legendre.py -> build/lib.linux-i686-2.6/numpy/polynomial
creating build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/indexing.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/ufuncs.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/jargon.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/subclassing.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/misc.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/glossary.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/methods_vs_functions.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/constants.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/creation.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/io.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/basics.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/structured_arrays.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/__init__.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/internals.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/howtofind.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/byteswapping.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/broadcasting.py -> build/lib.linux-i686-2.6/numpy/doc
copying numpy/doc/performance.py -> build/lib.linux-i686-2.6/numpy/doc
running build_clib
customize UnixCCompiler
customize UnixCCompiler using build_clib
building 'npymath' library
compiling C sources
C compiler: mips-openwrt-linux-uclibc-gcc -DNDEBUG -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/include -I/usr/local/src/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/usr/local/src/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/include -fPIC

creating build/temp.linux-i686-2.6
creating build/temp.linux-i686-2.6/build
creating build/temp.linux-i686-2.6/build/src.linux-i686-2.6
creating build/temp.linux-i686-2.6/build/src.linux-i686-2.6/numpy
creating build/temp.linux-i686-2.6/build/src.linux-i686-2.6/numpy/core
creating build/temp.linux-i686-2.6/build/src.linux-i686-2.6/numpy/core/src
creating build/temp.linux-i686-2.6/build/src.linux-i686-2.6/numpy/core/src/npymath
creating build/temp.linux-i686-2.6/numpy
creating build/temp.linux-i686-2.6/numpy/core
creating build/temp.linux-i686-2.6/numpy/core/src
creating build/temp.linux-i686-2.6/numpy/core/src/npymath
compile options: '-Inumpy/core/include -Ibuild/src.linux-i686-2.6/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/include -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include/python2.6 -Ibuild/src.linux-i686-2.6/numpy/core/src/multiarray -Ibuild/src.linux-i686-2.6/numpy/core/src/umath -c'
mips-openwrt-linux-uclibc-gcc: build/src.linux-i686-2.6/numpy/core/src/npymath/npy_math_complex.c
build/src.linux-i686-2.6/numpy/core/src/npymath/npy_math_complex.c:1: note: someone does not honour COPTS correctly, passed 2 times
mips-openwrt-linux-uclibc-gcc: numpy/core/src/npymath/halffloat.c
numpy/core/src/npymath/halffloat.c:1: note: someone does not honour COPTS correctly, passed 2 times
mips-openwrt-linux-uclibc-gcc: build/src.linux-i686-2.6/numpy/core/src/npymath/npy_math.c
build/src.linux-i686-2.6/numpy/core/src/npymath/npy_math.c:1: note: someone does not honour COPTS correctly, passed 2 times
mips-openwrt-linux-uclibc-gcc: build/src.linux-i686-2.6/numpy/core/src/npymath/ieee754.c
build/src.linux-i686-2.6/numpy/core/src/npymath/ieee754.c:1: note: someone does not honour COPTS correctly, passed 2 times
numpy/core/src/npymath/ieee754.c.src:588:20: error: fenv.h: No such file or directory
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_divbyzero':
numpy/core/src/npymath/ieee754.c.src:595: error: 'FE_DIVBYZERO' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src:595: error: (Each undeclared identifier is reported only once
numpy/core/src/npymath/ieee754.c.src:595: error: for each function it appears in.)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_overflow':
numpy/core/src/npymath/ieee754.c.src:600: error: 'FE_OVERFLOW' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_underflow':
numpy/core/src/npymath/ieee754.c.src:605: error: 'FE_UNDERFLOW' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_invalid':
numpy/core/src/npymath/ieee754.c.src:610: error: 'FE_INVALID' undeclared (first use in this function)
build/src.linux-i686-2.6/numpy/core/src/npymath/ieee754.c:1: note: someone does not honour COPTS correctly, passed 2 times
numpy/core/src/npymath/ieee754.c.src:588:20: error: fenv.h: No such file or directory
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_divbyzero':
numpy/core/src/npymath/ieee754.c.src:595: error: 'FE_DIVBYZERO' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src:595: error: (Each undeclared identifier is reported only once
numpy/core/src/npymath/ieee754.c.src:595: error: for each function it appears in.)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_overflow':
numpy/core/src/npymath/ieee754.c.src:600: error: 'FE_OVERFLOW' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_underflow':
numpy/core/src/npymath/ieee754.c.src:605: error: 'FE_UNDERFLOW' undeclared (first use in this function)
numpy/core/src/npymath/ieee754.c.src: In function 'npy_set_floatstatus_invalid':
numpy/core/src/npymath/ieee754.c.src:610: error: 'FE_INVALID' undeclared (first use in this function)
error: Command "mips-openwrt-linux-uclibc-gcc -DNDEBUG -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/include -I/usr/local/src/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/usr/local/src/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/include -fPIC -Inumpy/core/include -Ibuild/src.linux-i686-2.6/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/include -I/usr/local/src/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include/python2.6 -Ibuild/src.linux-i686-2.6/numpy/core/src/multiarray -Ibuild/src.linux-i686-2.6/numpy/core/src/umath -c build/src.linux-i686-2.6/numpy/core/src/npymath/ieee754.c -o build/temp.linux-i686-2.6/build/src.linux-i686-2.6/numpy/core/src/npymath/ieee754.o" failed with exit status 1
make[2]: *** [/usr/local/src/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/numpy-1.6.1/.built] Error 1
make[2]: Leaving directory `/usr/local/src/backfire/feeds/packages/lang/numpy'
make[1]: *** [package/feeds/packages/numpy/compile] Error 2
make[1]: Leaving directory `/usr/local/src/backfire'
make: *** [package/feeds/packages/numpy/compile] Error 2

I was following previous one to make it. and I am stuck at this stage.

I found related article poring numpy on android here. but hard to reproduce.
https://groups.google.com/group/android … d0dc5048fb

and another approach could be using bento build script. but not tried.
https://github.com/numpy/numpy/blob/master/bento.info

(Last edited by nikescar on 20 Mar 2012, 03:35)

I ackowledged that numpy on dir-825 is imposibble because of fpu and floating point calculation. So switched to x86 architecture and compiled well but don't know if its working.
Makefile

#
# Copyright (C) 2008-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=numpy
PKG_VERSION:=1.6.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/
PKG_MD5SUM:=2bce18c08fc4fce461656f0f4dd9103e

PKG_BUILD_DEPENDS:=python

include $(INCLUDE_DIR)/package.mk
$(call include_mk, python-package.mk)

define Package/numpy
  SUBMENU:=Python
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=numpy
  URL:=http://numpy.sf.net
  DEPENDS:=+python-mini  @TARGET_x86||TARGET_olpc||TARGET_uml 
endef

define Package/numpy/description
  Numpy
endef

define PyPackage/numpy/filespec
+|$(PYTHON_PKG_DIR)/numpy
endef

define Build/Compile
        $(if $(Build/Compile/PyMod),,@echo Python packaging code not found.; false)
        $(call Build/Compile/PyMod,., \
                install --prefix="$(PKG_INSTALL_DIR)/usr", \
        )
endef

$(eval $(call PyPackage,numpy))
$(eval $(call BuildPackage,numpy))

succeed on building and packaging. but don't know if its working.

turns out, its not working. segmentation fault.

root@OpenWrt /root [17]# python
Python 2.6.4 (r264:75706, Jul 14 2011, 17:36:43)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.test()
Running unit tests for numpy
NumPy version 1.6.1
NumPy is installed in /usr/lib/python2.6/site-packages/numpy
Python version 2.6.4 (r264:75706, Jul 14 2011, 17:36:43) [GCC 4.1.2]
nose version 1.1.2
....S............................................................................................................... .................................................................................................................... .............................................S......................F............................................... .................................................................................................................... .........................................................................................F.......................... .........................................................................................................SSS........ .................................................................................................................... .................................................................................................................... ...../usr/lib/python2.6/site-packages/numpy/core/tests/test_umath.py:786: RuntimeWarning: divide by zero encountered  in log10
  return not np.isfinite(np.log10(info.tiny/info.eps))
.................................K...K..........................................................FF....F............. ...............K......................K............................................................................. .............................S...................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... .................................................................................................................... ....Segmentation fault
root@OpenWrt /root [18]# logout
root@OpenWrt /var/log [45]# logread|tail
Mar 20 22:48:20 OpenWrt user.info kernel: python[2259]: segfault at 4222 ip 00004222 sp bfee663c error 4 in python2.6[8048000+10a000]
root@OpenWrt /var/log [46]#

(Last edited by nikescar on 20 Mar 2012, 23:23)

why don't you choose python-full rather than python-mini?

I was able to get this working with your Makefile; however I had to add two patches, one of which works in a non-standard way. I needed to edit site.cfg in the numpy sources to point to the correct python libraries. If anyone is interested, I can post this stuff and see if there is a way to get the linker to work without this work-around. At that point, I'd be happy to submit it.

PS. I changed "python-mini" to "python".

(Last edited by cjpatton on 5 May 2012, 00:40)

Hello, could you please post the Makefile and patch you used to compile numpy?
Thanks
Andrea

The discussion might have continued from here.