diff options
author | Mike Gilbert <floppym@gentoo.org> | 2014-06-29 14:24:22 +0000 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2014-06-29 14:24:22 +0000 |
commit | 23edd11b0635ed6aecda8bbfa51b54e802c50ae3 (patch) | |
tree | 9398ba3987c1c6d8239132dca064e57184ad5020 /eclass | |
parent | Version bump (diff) | |
download | gentoo-2-23edd11b0635ed6aecda8bbfa51b54e802c50ae3.tar.gz gentoo-2-23edd11b0635ed6aecda8bbfa51b54e802c50ae3.tar.bz2 gentoo-2-23edd11b0635ed6aecda8bbfa51b54e802c50ae3.zip |
Attempt to use a UTF-8 locale if one is available to avoid errors when setup.py calls open() with no encoding.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 7 | ||||
-rw-r--r-- | eclass/distutils-r1.eclass | 4 | ||||
-rw-r--r-- | eclass/python-utils-r1.eclass | 37 |
3 files changed, 45 insertions, 3 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index a4d57c00c1f0..c53669650dca 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for eclass directory # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1305 2014/06/29 08:32:46 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1306 2014/06/29 14:24:22 floppym Exp $ + + 29 Jun 2014; Mike Gilbert <floppym@gentoo.org> distutils-r1.eclass, + python-utils-r1.eclass: + Attempt to use a UTF-8 locale if one is available to avoid errors when + setup.py calls open() with no encoding. 29 Jun 2014; Michał Górny <mgorny@gentoo.org> multilib-build.eclass: Fix handling empty MULTILIB_COMPAT. diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index e5a5cd4e9460..a564e7c59bb7 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.99 2014/06/22 07:01:37 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.100 2014/06/29 14:24:22 floppym Exp $ # @ECLASS: distutils-r1 # @MAINTAINER: @@ -690,6 +690,8 @@ distutils-r1_src_prepare() { } distutils-r1_src_configure() { + python_export_utf8_locale + if declare -f python_configure >/dev/null; then _distutils-r1_run_foreach_impl python_configure fi diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index cff0429c2653..5376454ee15b 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.58 2014/06/19 15:10:55 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.59 2014/06/29 14:24:22 floppym Exp $ # @ECLASS: python-utils-r1 # @MAINTAINER: @@ -1110,5 +1110,40 @@ _python_get_wrapper_path() { fi } +# @FUNCTION: python_export_utf8_locale +# @RETURN: 0 on success, 1 on failure. +# @DESCRIPTION: +# Attempts to export a usable UTF-8 locale in the LC_CTYPE variable. Does +# nothing if LC_ALL is defined, or if the current locale uses a UTF-8 charmap. +# This may be used to work around the quirky open() behavior of python3. +python_export_utf8_locale() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ $(locale charmap) != UTF-8 ]]; then + if [[ -n ${LC_ALL} ]]; then + ewarn "LC_ALL is set to a locale with a charmap other than UTF-8." + ewarn "This may trigger build failures in some python packages." + return 1 + fi + + # Try English first, then everything else. + local lang locales="en_US.UTF-8 $(locale -a)" + + for lang in ${locales}; do + if [[ $(LC_CTYPE=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then + export LC_CTYPE=${lang} + return 0 + fi + done + + ewarn "Could not find a UTF-8 locale. This may trigger build failures in" + ewarn "some python packages. Please ensure that a UTF-8 locale is listed in" + ewarn "/etc/locale.gen and run locale-gen." + return 1 + fi + + return 0 +} + _PYTHON_UTILS_R1=1 fi |