From: Mike Gilbert <floppym@gentoo.org>
To: gentoo-python@lists.gentoo.org
Cc: python@gentoo.org
Subject: [gentoo-python] [PATCHv2] Attempt to export a UTF-8 locale in distutils-r1
Date: Sun, 22 Jun 2014 10:54:04 -0400 [thread overview]
Message-ID: <1403448844-11727-1-git-send-email-floppym@gentoo.org> (raw)
In-Reply-To: <1403395310-19092-1-git-send-email-floppym@gentoo.org>
Revised with mgorny's suggestions.
Index: distutils-r1.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v
retrieving revision 1.98
diff -u -r1.98 distutils-r1.eclass
--- distutils-r1.eclass 21 Jun 2014 08:14:18 -0000 1.98
+++ distutils-r1.eclass 22 Jun 2014 14:50:08 -0000
@@ -684,6 +684,8 @@
}
distutils-r1_src_configure() {
+ python_export_utf8_locale
+
if declare -f python_configure >/dev/null; then
_distutils-r1_run_foreach_impl python_configure
fi
Index: python-utils-r1.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v
retrieving revision 1.58
diff -u -r1.58 python-utils-r1.eclass
--- python-utils-r1.eclass 19 Jun 2014 15:10:55 -0000 1.58
+++ python-utils-r1.eclass 22 Jun 2014 14:50:08 -0000
@@ -1110,5 +1110,40 @@
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
prev parent reply other threads:[~2014-06-22 14:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 0:01 [gentoo-python] [PATCH] Attempt to export a UTF-8 locale in distutils-r1 Mike Gilbert
2014-06-22 6:56 ` Michał Górny
2014-06-22 14:18 ` Mike Gilbert
2014-06-22 14:54 ` Mike Gilbert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403448844-11727-1-git-send-email-floppym@gentoo.org \
--to=floppym@gentoo.org \
--cc=gentoo-python@lists.gentoo.org \
--cc=python@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox