提交 ada26801 编写于 作者: D Daniel P. Berrangé

build: force a UTF-8 locale for python

Python3 versions less than 3.7 have very unhelpful handling
of the C locale where they assume data is 7-bit only. This
violates POSIX which requires the C locale to be 8-bit clean.
Python3 >= 3.7 now assumes that the C locale is always UTF-8.

Set env variables to force LC_CTYPE to en_US.UTF-8 so that
we get UTF-8 handling on all python versions. Note we do
not use C.UTF-8 since not all C libraries support that.
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 851dba3f
......@@ -69,7 +69,7 @@ NEWS: \
$(srcdir)/docs/news.xml \
>$@-tmp \
|| { rm -f $@-tmp; exit 1; }; \
$(PYTHON) $(srcdir)/docs/reformat-news.py $@-tmp >$@ \
$(RUNUTF8) $(PYTHON) $(srcdir)/docs/reformat-news.py $@-tmp >$@ \
|| { rm -f $@-tmp; exit 1; }; \
rm -f $@-tmp; \
fi
......
......@@ -708,6 +708,14 @@ AC_PATH_PROG([FLAKE8], [flake8])
if test -z "$FLAKE8"; then
AC_MSG_WARN(['flake8' binary is required to check python code style])
fi
dnl Python3 < 3.7 treats the C locale as 7-bit only.
dnl We must force env vars so it treats it as UTF-8
dnl regardless of the user's locale.
RUNUTF8="LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8"
AC_SUBST(RUNUTF8)
AC_PATH_PROG([PERL], [perl])
if test -z "$PERL"; then
AC_MSG_ERROR(['perl' binary is required to build libvirt])
......
......@@ -319,7 +319,8 @@ $(APIBUILD_STAMP): $(srcdir)/apibuild.py \
$(top_srcdir)/src/util/virerror.c \
$(top_srcdir)/src/util/virevent.c \
$(top_srcdir)/src/util/virtypedparam.c
$(AM_V_GEN)srcdir=$(srcdir) builddir=$(builddir) $(PYTHON) $(APIBUILD)
$(AM_V_GEN)srcdir=$(srcdir) builddir=$(builddir) \
$(RUNUTF8) $(PYTHON) $(APIBUILD)
touch $@
......
......@@ -63,8 +63,8 @@ $(ESX_DRIVER_GENERATED): $(ESX_GENERATED_STAMP)
$(ESX_GENERATED_STAMP): $(srcdir)/esx/esx_vi_generator.input \
$(srcdir)/esx/esx_vi_generator.py
$(AM_V_GEN)srcdir=$(srcdir) $(PYTHON) $(srcdir)/esx/esx_vi_generator.py \
&& touch $@
$(AM_V_GEN)srcdir=$(srcdir) $(RUNUTF8) $(PYTHON) \
$(srcdir)/esx/esx_vi_generator.py && touch $@
MAINTAINERCLEANFILES += $(ESX_DRIVER_GENERATED) $(ESX_GENERATED_STAMP)
......
......@@ -41,7 +41,7 @@ $(HYPERV_DRIVER_GENERATED): $(HYPERV_GENERATED_STAMP)
$(HYPERV_GENERATED_STAMP): $(srcdir)/hyperv/hyperv_wmi_generator.input \
$(srcdir)/hyperv/hyperv_wmi_generator.py
$(AM_V_GEN)srcdir=$(srcdir) $(PYTHON) \
$(AM_V_GEN)srcdir=$(srcdir) $(RUNUTF8) $(PYTHON) \
$(srcdir)/hyperv/hyperv_wmi_generator.py \
&& touch $@
......
......@@ -300,7 +300,7 @@ util/virkeycodetable_%.h: $(srcdir)/keycodemapdb/data/keymaps.csv \
$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeycodetable_,,' \
-e 's,\.h,,'` && \
$(MKDIR_P) util/ && \
$(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang stdc --varname virKeyCodeTable_$$NAME code-table \
$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
mv $@-tmp $@ || rm -f $@-tmp
......@@ -310,7 +310,7 @@ util/virkeynametable_%.h: $(srcdir)/keycodemapdb/data/keymaps.csv \
$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeynametable_,,' \
-e 's,\.h,,'` && \
$(MKDIR_P) util/ && \
$(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang stdc --varname virKeyNameTable_$$NAME name-table \
$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
mv $@-tmp $@ || rm -f $@-tmp
......@@ -320,7 +320,7 @@ util/virkeycode-%.pod: $(srcdir)/keycodemapdb/data/keymaps.csv \
$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeycode-,,' \
-e 's,\.pod,,'` && \
$(MKDIR_P) util/ && \
$(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang pod \
--varname "virkeycode-$$NAME - Key code values for $$NAME" \
code-docs \
......@@ -332,7 +332,7 @@ util/virkeyname-%.pod: $(srcdir)/keycodemapdb/data/keymaps.csv \
$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeyname-,,' \
-e 's,\.pod,,'` && \
$(MKDIR_P) util/ && \
$(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang pod \
--varname "virkeyname-$$NAME - Key name values for $$NAME" \
name-docs \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册