Skip to contentSkip to conversation

Misc Python fixes and updates

PATCH New Thomas Petazzoni 1 participant 6 messages Jul 23, 2014 – Jul 27, 2014

lore
Share & tools
lore
#0 lore raw

cover Misc Python fixes and updates

Hello,

Here are four patches doing misc Python fixes and updates. Patch 1 and 2 combined solve one autobuilder issues (decimal module does not build on configurations where fenv is not available), and patch 4 solves another autobuilder issue (python-numpy does not build on configurations where fenv is not available).

Thanks,

Thomas

Thomas Petazzoni (4):
mpdecimal: new package
python3: optional decimal module support
python3: define license and license files
python-numpy: add patch to fix build on uClibc

 package/Config.in                                  |  1 +
 package/mpdecimal/Config.in                        | 10 +++
 package/mpdecimal/mpdecimal.mk                     | 24 +++++++
 .../python-numpy-0001-no-fenv-on-uclibc.patch      | 79 ++++++++++++++++++++++
 package/python3/Config.in                          |  6 ++
 package/python3/python3-111-optional-decimal.patch | 53 +++++++++++++++
 package/python3/python3.mk                         |  9 +++
 7 files changed, 182 insertions(+)
 create mode 100644 package/mpdecimal/Config.in
 create mode 100644 package/mpdecimal/mpdecimal.mk
 create mode 100644 package/python-numpy/python-numpy-0001-no-fenv-on-uclibc.patch
 create mode 100644 package/python3/python3-111-optional-decimal.patch
Signature · 1 line
2.0.0
#1 lore raw

PATCH 1/4 mpdecimal: new package

---
 package/Config.in              |  1 +
 package/mpdecimal/Config.in    | 10 ++++++++++
 package/mpdecimal/mpdecimal.mk | 24 ++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
 create mode 100644 package/mpdecimal/Config.in
 create mode 100644 package/mpdecimal/mpdecimal.mk
package/Config.in +1 -0
index 703fd3d..f921b0a 100644
@@ -856,6 +856,7 @@ menu "Other"
 	source "package/linux-pam/Config.in"
 	source "package/lttng-libust/Config.in"
 	source "package/mpc/Config.in"
+	source "package/mpdecimal/Config.in"
 	source "package/mpfr/Config.in"
 	source "package/msgpack/Config.in"
 	source "package/mtdev2tuio/Config.in"
package/mpdecimal/Config.in new file +10 -0
new file mode 100644
index 0000000..929d415
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_MPDECIMAL
+	bool "mpdecimal"
+	help
+	  mpdecimal is a package for correctly-rounded arbitrary
+	  precision decimal floating point arithmetic. Starting from
+	  version 2.4, mpdecimal includes only the libmpdec
+	  library. Further mpdecimal development will focus
+	  exclusively on libmpdec.
+
+	  http://www.bytereef.org/mpdecimal/
package/mpdecimal/mpdecimal.mk new file +24 -0
new file mode 100644
index 0000000..cb028a5
@@ -0,0 +1,24 @@
+################################################################################
+#
+# mpdecimal
+#
+################################################################################
+
+MPDECIMAL_SITE = http://www.bytereef.org/software/mpdecimal/releases/
+MPDECIMAL_VERSION = 2.4.0
+MPDECIMAL_INSTALL_STAGING = YES
+MPDECIMAL_LICENSE = BSD-2c
+MPDECIMAL_LICENSE_FILES = LICENSE.txt
+MPDECIMAL_CONF_OPT = LD="$(TARGET_CC)"
+
+# On i386, by default, mpdecimal tries to uses <fenv.h> which is not
+# available in musl/glibc. So in this case, we tell mpdecimal to use
+# the generic 32 bits code, which is anyway the one used on ARM,
+# PowerPC, etc.
+ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),)
+ifeq ($(BR2_i386),y)
+MPDECIMAL_CONF_ENV += MACHINE=ansi32
+endif
+endif
+
+$(eval $(autotools-package))
Signature · 1 line
2.0.0
#2 lore raw

PATCH 2/4 python3: optional decimal module support

In reply to Thomas Petazzoni

This commit makes the decimal module support optional: since Python 3.3 it relies on an external library. The source code of this library is available built-in as part of the Python sources, but in Buildroot we generally prefer to use the external library when possible.

To achieve this, this commit adds a patch to Python that is similar to the one we use for expat support, but this time for the libmpdec/mpdecimal library.

As a consequence, since mpdecimal now builds properly even when <fenv.h> is not available (on i386), this commit fixes:

http://autobuild.buildroot.org/results/b64/b64d5c941a7cac00619da3a0696939f86a8eafc2/

---
 package/python3/Config.in                          |  6 +++
 package/python3/python3-111-optional-decimal.patch | 53 ++++++++++++++++++++++
 package/python3/python3.mk                         |  7 +++
 3 files changed, 66 insertions(+)
 create mode 100644 package/python3/python3-111-optional-decimal.patch
package/python3/Config.in +6 -0
index 12928f6..3e193c8 100644
@@ -54,6 +54,12 @@ config BR2_PACKAGE_PYTHON3_CURSES
 	help
 	  curses module for Python3.
 
+config BR2_PACKAGE_PYTHON3_DECIMAL
+	select BR2_PACKAGE_MPDECIMAL
+	bool "decimal module"
+	help
+	  decimal module for Python3.
+
 config BR2_PACKAGE_PYTHON3_PYEXPAT
 	select BR2_PACKAGE_EXPAT
 	bool "pyexpat"
package/python3/python3-111-optional-decimal.patch new file +53 -0

53 lines not on this page · raw message

package/python3/python3.mk +7 -0
index 1591ac9..3aa22b2 100644
@@ -51,6 +51,13 @@ else
 PYTHON3_CONF_OPT += --disable-curses
 endif
 
+ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL),y)
+PYTHON3_DEPENDENCIES += mpdecimal
+PYTHON3_CONF_OPT += --with-libmpdec=system
+else
+PYTHON3_CONF_OPT += --with-libmpdec=none
+endif
+
 ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
 PYTHON3_DEPENDENCIES += expat
 PYTHON3_CONF_OPT += --with-expat=system
Signature · 1 line
2.0.0
#3 lore raw

PATCH 3/4 python3: define license and license files

In reply to Thomas Petazzoni
---
 package/python3/python3.mk | 2 ++
 1 file changed, 2 insertions(+)
package/python3/python3.mk +2 -0
index 3aa22b2..4941316 100644
@@ -8,6 +8,8 @@ PYTHON3_VERSION_MAJOR = 3.4
 PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).1
 PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.xz
 PYTHON3_SITE = http://python.org/ftp/python/$(PYTHON3_VERSION)
+PYTHON3_LICENSE = Python software foundation license v2, others
+PYTHON3_LICENSE_FILES = LICENSE
 
 # Python needs itself and a "pgen" program to build itself, both being
 # provided in the Python sources. So in order to cross-compile Python,
Signature · 1 line
2.0.0
#4 lore raw

PATCH 4/4 python-numpy: add patch to fix build on uClibc

In reply to Thomas Petazzoni

Fixes:

http://autobuild.buildroot.org/results/01d/01da44bc4b644a46326d8fbd87708b7a98971487/

---
 .../python-numpy-0001-no-fenv-on-uclibc.patch      | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 package/python-numpy/python-numpy-0001-no-fenv-on-uclibc.patch
package/python-numpy/python-numpy-0001-no-fenv-on-uclibc.patch new file +79 -0
new file mode 100644
index 0000000..633dbcd
@@ -0,0 +1,79 @@
+Don't use <fenv.h> on uClibc
+
+The python-numpy code already has provisions to not use <fenv.h> when
+not available. However, it uses __GLIBC__ to know whether fenv.h is
+available or not, but uClibc defines __GLIBC__, so python-numpy thinks
+fenv.h is available.
+
+This patch fixes that by changing all defined(__GLIBC__) occurences by
+(defined(__GLIBC__) && !defined(__UCLIBC__)).
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/numpy/core/include/numpy/ufuncobject.h
+===================================================================
+--- a/numpy/core/include/numpy/ufuncobject.h
++++ b/numpy/core/include/numpy/ufuncobject.h
+@@ -413,11 +413,11 @@
+         (void) fpsetsticky(0); \
+         }
+ 
+-#elif defined(__GLIBC__) || defined(__APPLE__) || \
++#elif (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || \
+       defined(__CYGWIN__) || defined(__MINGW32__) || \
+       (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+ 
+-#if defined(__GLIBC__) || defined(__APPLE__) || \
++#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || \
+     defined(__MINGW32__) || defined(__FreeBSD__)
+ #include <fenv.h>
+ #elif defined(__CYGWIN__)
+Index: b/numpy/core/src/npymath/ieee754.c.src
+===================================================================
+--- a/numpy/core/src/npymath/ieee754.c.src
++++ b/numpy/core/src/npymath/ieee754.c.src
+@@ -586,11 +586,11 @@
+ }
+ 
+ 
+-#elif defined(__GLIBC__) || defined(__APPLE__) || \
++#elif (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || \
+       defined(__CYGWIN__) || defined(__MINGW32__) || \
+       (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+ 
+-# if defined(__GLIBC__) || defined(__APPLE__) || \
++# if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || \
+      defined(__MINGW32__) || defined(__FreeBSD__)
+ #  include <fenv.h>
+ # elif defined(__CYGWIN__)
+Index: b/numpy/numarray/_capi.c
+===================================================================
+--- a/numpy/numarray/_capi.c
++++ b/numpy/numarray/_capi.c
+@@ -10,7 +10,7 @@
+ #include <sys/param.h>
+ #endif
+ 
+-#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
++#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+ #include <fenv.h>
+ #elif defined(__CYGWIN__)
+ #include "numpy/fenv/fenv.h"
+@@ -258,7 +258,7 @@
+ }
+ 
+ /* Likewise for Integer overflows */
+-#if defined(__GLIBC__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
++#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+ static int int_overflow_error(Float64 value) { /* For x86_64 */
+     feraiseexcept(FE_OVERFLOW);
+     return (int) value;
+@@ -3007,7 +3007,7 @@
+     return retstatus;
+ }
+ 
+-#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
++#elif (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 502114))
+ 
+ static int
+ NA_checkFPErrors(void)
Signature · 1 line
2.0.0
#5 lore raw

cover Misc Python fixes and updates

In reply to Thomas Petazzoni

Hello,

Quoted 5 lines · Thomas Petazzoni

Thomas Petazzoni (4):
mpdecimal: new package
python3: optional decimal module support
python3: define license and license files
python-numpy: add patch to fix build on uClibc

Since there was no review, and those patches are fixing build issues, I applied them. Don't hesitate to let me know if there's anything you don't agree with in those patches.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com