dependencies: build a host python2 if no suitable one can be found
PATCH v4 1/2 dependencies: build a host python2 if no suitable one can be found
Some distros choose to change the /usr/bin/python binary, making it pointed to python3 instead of python2.
This may have some bad consequences for packages that uses some non-python3-compliant python scripts in their build system (eg. in install or post-install scripts).
This patch checks for a suitable python2 version (2.6 or 2.7) on the host system, and declares the following variables:
- PYTHON2: pointing to the host python2 binary;
- NEED_PYTHON2: sets to "host-python" if no python2 binary has been found.
This way, a package using some python2 scripts must:
- adds $(NEED_PYTHON2) to its dependency list;
- sets $(PYTHON2) as the python binary to be used.
A side effect of this patch is getting rid of any host python. Buildroot can runs on a host without python, or with a too old python2 version, or with only python3; in such case, $(NEED_PYTHON2) should be added to the dependency list. So, we can get rid of the python dependency check.
---
Changelog:
Changes since v3:
- minor fix
Changes since v2:
- misc. fixes and cleanup
Changes since v1:
- use support/dependency infrastructure
- rename some symbols
create mode 100644 support/dependencies/check-host-python2.mk create mode 100755 support/dependencies/check-host-python2.sh
support/dependencies/check-host-python2.mk new file +6 -0
@@ -0,0 +1,6 @@ +PYTHON2 = $(call suitable-host-package,python2) + +ifeq ($(PYTHON2),) + NEED_PYTHON2 = host-python + PYTHON2 = $(HOST_DIR)/usr/bin/python +endif
support/dependencies/check-host-python2.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh + +candidates="python python2" + +for candidate in ${candidates} ; do + which ${candidate} &>/dev/null || continue + # restrict version of python2 to 2.6 or 2.7 + if ${candidate} --version 2>&1 | grep -q 'Python 2\.[6-7].*' ; then + # found a valid candidate, so quit now + echo $(which ${candidate}) + exit + fi +done
support/dependencies/dependencies.sh +1 -1
@@ -131,7 +131,7 @@ if ! $SHELL --version 2>&1 | grep -q '^GNU bash'; then fi; # Check that a few mandatory programs are installed -for prog in awk bison flex msgfmt makeinfo patch gzip bzip2 perl tar wget cpio python unzip rsync ${DL_TOOLS} ; do +for prog in awk bison flex msgfmt makeinfo patch gzip bzip2 perl tar wget cpio unzip rsync ${DL_TOOLS} ; do if ! which $prog > /dev/null ; then /bin/echo -e "\nYou must install '$prog' on your build machine"; if test $prog = "makeinfo" ; then
Signature · 1 line
1.7.11.2
PATCH v4 1/2 dependencies: build a host python2 if no suitable one can be found
Hi all,
Reviving an old thread...
2012/7/16 Samuel Martin <[email protected]>:
Quoted 12 lines
Some distros choose to change the
/usr/bin/pythonbinary, making it pointed to python3 instead of python2.This may have some bad consequences for packages that uses some non-python3-compliant python scripts in their build system (eg. in install or post-install scripts).
This patch checks for a suitable python2 version (2.6 or 2.7) on the host system, and declares the following variables:
- PYTHON2: pointing to the host python2 binary;
-NEED_PYTHON2: sets to "host-python" if no python2 binary has been found.
Quoted 9 lines
This way, a package using some python2 scripts must:
- adds $(NEED_PYTHON2) to its dependency list;
- sets $(PYTHON2) as the python binary to be used.A side effect of this patch is getting rid of any host python. Buildroot can runs on a host without python, or with a too old python2 version, or with only python3; in such case, $(NEED_PYTHON2) should be added to the dependency list. So, we can get rid of the python dependency check.
Just to let you know that this patch may also fix some issues with scons, which does not seem to support python3 yet.
Any comment about this?
Regards,
Signature · 1 line
Sam
PATCH v4 2/2 libglib2: fix install even if the host python binary refers to python3
In reply to Samuel MartinThe libglib2's build system uses some python2 scripts in the install rules.
This patch ensures to have a valid host python2 binary and enforces this python2 binary at configure-time.
package/libglib2/libglib2.mk +7 -2
@@ -42,7 +42,10 @@ LIBGLIB2_CONF_ENV = \ ac_use_included_regex=no gl_cv_c_restrict=no \ ac_cv_path_GLIB_GENMARSHAL=$(HOST_DIR)/usr/bin/glib-genmarshal ac_cv_prog_F77=no \ ac_cv_func_posix_getgrgid_r=no \ - gt_cv_c_wchar_t=$(if $(BR2_USE_WCHAR),yes,no) + gt_cv_c_wchar_t=$(if $(BR2_USE_WCHAR),yes,no) \ + ac_cv_path_PYTHON=$(PYTHON2) + +HOST_LIBGLIB2_CONF_ENV += ac_cv_path_PYTHON=$(PYTHON2) # old uClibc versions don't provide qsort_r ifeq ($(BR2_UCLIBC_VERSION_0_9_31)$(BR2_UCLIBC_VERSION_0_9_32)$(BR2_TOOLCHAIN_CTNG_uClibc)$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
@@ -57,7 +60,9 @@ HOST_LIBGLIB2_CONF_OPT = \ LIBGLIB2_DEPENDENCIES = host-pkg-config host-libglib2 libffi zlib $(if $(BR2_NEEDS_GETTEXT),gettext libintl) -HOST_LIBGLIB2_DEPENDENCIES = host-pkg-config host-libffi host-zlib +HOST_LIBGLIB2_DEPENDENCIES = host-pkg-config host-libffi host-zlib $(NEED_PYTHON2) + +LIBGLIB2_DEPENDENCIES += $(NEED_PYTHON2) ifneq ($(BR2_ENABLE_LOCALE),y) LIBGLIB2_DEPENDENCIES += libiconv
Signature · 1 line
1.7.11.2