All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/2] support/dependencies: add a check for python3
Date: Tue, 12 Mar 2019 22:28:23 +0100	[thread overview]
Message-ID: <20190312212823.GH25009@scaer> (raw)
In-Reply-To: <20190310165917.24325-1-romain.naour@gmail.com>

Romain, All,

On 2019-03-10 17:59 +0100, Romain Naour spake thusly:
> Since version 2.29, glibc requires python 3.4 or later to build the GNU C Library [1].
> 
> We add a new check to verify the version of python3 interpreter installed on the host.
> If no suitable python3 interpreter is found, define BR2_PYTHON3_HOST_DEPENDENCY to add
> host-python3 in package dependencies when needed.
> 
> [1] https://www.sourceware.org/ml/libc-alpha/2019-01/msg00723.html
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> ---
>  support/dependencies/check-host-python3.mk | 13 ++++++++++
>  support/dependencies/check-host-python3.sh | 41 ++++++++++++++++++++++++++++++
>  2 files changed, 54 insertions(+)
>  create mode 100644 support/dependencies/check-host-python3.mk
>  create mode 100755 support/dependencies/check-host-python3.sh
> 
> diff --git a/support/dependencies/check-host-python3.mk b/support/dependencies/check-host-python3.mk
> new file mode 100644
> index 0000000000..ceb48c969e
> --- /dev/null
> +++ b/support/dependencies/check-host-python3.mk
> @@ -0,0 +1,13 @@
> +# Since version 2.29, glibc requires python 3.4 or later to build the GNU C Library.
> +# https://www.sourceware.org/ml/libc-alpha/2019-01/msg00723.html
> +
> +# Set this to either 3.4 or higher, depending on the highest minimum
> +# version required by any of the packages bundled in Buildroot. If a
> +# package is bumped or a new one added, and it requires a higher
> +# version, our package infra will catch it and whine.
> +#
> +BR2_PYTHON3_VERSION_MIN = 3.4
> +
> +ifeq (,$(call suitable-host-package,python3,$(BR2_PYTHON3_VERSION_MIN) python3 python))

This call is turned into:

    $(shell support/dependencies/check-host-python3.sh 3.4 python3 python)

which means that support/dependencies/check-host-python3.sh is called
with three arguments, not two, which means that...

> +BR2_PYTHON3_HOST_DEPENDENCY = host-python3
> +endif
> diff --git a/support/dependencies/check-host-python3.sh b/support/dependencies/check-host-python3.sh
> new file mode 100755
> index 0000000000..e5745fa7c4
> --- /dev/null
> +++ b/support/dependencies/check-host-python3.sh
> @@ -0,0 +1,41 @@
> +#!/bin/sh
> +
> +# prevent shift error
> +[ $# -lt 2 ] && exit 1
> +
> +major_min="${1%.*}"
> +minor_min="${1#*.}"
> +
> +shift

... here we're left with two remaining arguments, and thus...

> +# The host python interpreter is already checked by dependencies.sh but
> +# it only check if the version is at least 2.7.
> +# We want to check the version number of the python3 interpreter even
> +# if Buildroot is able to use any version but some packages may require
> +# a more recent version.
> +python3_candidates="$1"

... here ${1} is only ever going to contain "python3", not
"python3 python" as you think it does. Does it?

> +for candidate in $python3_candidates ; do

The simplest is to drop the python3_candidates variable, and simply use:

    for candidate in "${@}"; do
        [...]
    done

Regards,
Yann E. MORIN.

> +	python3=`which $candidate 2>/dev/null`
> +	if [ ! -x "$python3" ]; then
> +		continue
> +	fi
> +	version=`$python3 -V 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-].*//g' -e '1q'`
> +
> +	major=`echo "$version" | cut -d. -f1`
> +	minor=`echo "$version" | cut -d. -f2`
> +
> +	if [ $major -lt $major_min ]; then
> +		# no suitable python3 found
> +		continue
> +	fi
> +
> +	if [ $major -eq $major_min -a $minor -lt $minor_min ]; then
> +		# no suitable python3 found
> +		continue
> +	fi
> +
> +	# suitable python3 found
> +	echo $python3
> +	break
> +done
> -- 
> 2.14.5
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

      parent reply	other threads:[~2019-03-12 21:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-10 16:59 [Buildroot] [PATCH 1/2] support/dependencies: add a check for python3 Romain Naour
2019-03-10 16:59 ` [Buildroot] [PATCH 2/2] package/glibc: bump to version 2.29 Romain Naour
2019-03-12 21:34   ` Yann E. MORIN
2019-03-12 13:09 ` [Buildroot] [PATCH 1/2] support/dependencies: add a check for python3 Adam Duskett
2019-03-12 14:03   ` Romain Naour
2019-03-12 21:28 ` Yann E. MORIN [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=20190312212823.GH25009@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.