1 |
Revised with mgorny's suggestions. |
2 |
|
3 |
Index: distutils-r1.eclass |
4 |
=================================================================== |
5 |
RCS file: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v |
6 |
retrieving revision 1.98 |
7 |
diff -u -r1.98 distutils-r1.eclass |
8 |
--- distutils-r1.eclass 21 Jun 2014 08:14:18 -0000 1.98 |
9 |
+++ distutils-r1.eclass 22 Jun 2014 14:50:08 -0000 |
10 |
@@ -684,6 +684,8 @@ |
11 |
} |
12 |
|
13 |
distutils-r1_src_configure() { |
14 |
+ python_export_utf8_locale |
15 |
+ |
16 |
if declare -f python_configure >/dev/null; then |
17 |
_distutils-r1_run_foreach_impl python_configure |
18 |
fi |
19 |
Index: python-utils-r1.eclass |
20 |
=================================================================== |
21 |
RCS file: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v |
22 |
retrieving revision 1.58 |
23 |
diff -u -r1.58 python-utils-r1.eclass |
24 |
--- python-utils-r1.eclass 19 Jun 2014 15:10:55 -0000 1.58 |
25 |
+++ python-utils-r1.eclass 22 Jun 2014 14:50:08 -0000 |
26 |
@@ -1110,5 +1110,40 @@ |
27 |
fi |
28 |
} |
29 |
|
30 |
+# @FUNCTION: python_export_utf8_locale |
31 |
+# @RETURN: 0 on success, 1 on failure. |
32 |
+# @DESCRIPTION: |
33 |
+# Attempts to export a usable UTF-8 locale in the LC_CTYPE variable. Does |
34 |
+# nothing if LC_ALL is defined, or if the current locale uses a UTF-8 charmap. |
35 |
+# This may be used to work around the quirky open() behavior of python3. |
36 |
+python_export_utf8_locale() { |
37 |
+ debug-print-function ${FUNCNAME} "${@}" |
38 |
+ |
39 |
+ if [[ $(locale charmap) != UTF-8 ]]; then |
40 |
+ if [[ -n ${LC_ALL} ]]; then |
41 |
+ ewarn "LC_ALL is set to a locale with a charmap other than UTF-8." |
42 |
+ ewarn "This may trigger build failures in some python packages." |
43 |
+ return 1 |
44 |
+ fi |
45 |
+ |
46 |
+ # Try English first, then everything else. |
47 |
+ local lang locales="en_US.UTF-8 $(locale -a)" |
48 |
+ |
49 |
+ for lang in ${locales}; do |
50 |
+ if [[ $(LC_CTYPE=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then |
51 |
+ export LC_CTYPE=${lang} |
52 |
+ return 0 |
53 |
+ fi |
54 |
+ done |
55 |
+ |
56 |
+ ewarn "Could not find a UTF-8 locale. This may trigger build failures in" |
57 |
+ ewarn "some python packages. Please ensure that a UTF-8 locale is listed in" |
58 |
+ ewarn "/etc/locale.gen and run locale-gen." |
59 |
+ return 1 |
60 |
+ fi |
61 |
+ |
62 |
+ return 0 |
63 |
+} |
64 |
+ |
65 |
_PYTHON_UTILS_R1=1 |
66 |
fi |