diff mbox series

[OpenWrt-Devel,5/6] build: switch to Python 3

Message ID 1560802136-4157-6-git-send-email-ynezz@true.cz
State Changes Requested
Delegated to: Petr Štetiar
Headers show
Series build: switch to Python 3 | expand

Commit Message

Petr Štetiar June 17, 2019, 8:08 p.m. UTC
This patch switches Python used in buildroot to Python 3 as Python 2.x
series is going to be EOL relatively soon[1].

 "Being the last of the Python 2.x series, 2.7 will have an extended
  period of maintenance. Specifically, 2.7 will receive bugfix support
  until January 1, 2020. After the last release, 2.7 will receive no
  support."

It seems like Python 3 is going to be needed in order to support Meson
build system which has gained some traction recently.

Build tested on following targets:

 ath79/generic
 imx6/generic
 ipq40xx/generic
 lantiq/xway
 layerscape/armv7 (broken)
 layerscape/armv8_32b (broken)
 layerscape/armv8_64b (broken)
 mvebu/cortexa72
 ramips/mt7621
 ramips/mt7620
 sunxi/cortexa7
 x86/64

Layerscape targets are unfortunately left broken as their ls-rcw
firmware package uses Python 2 and converting it to Python 3 would take
more then reasoanble amount of time (I've tried to fix it already) and
would be better fixed by someone who can even run test it.

Run tested on ath79 (Archer C7 v5), ipq40xx (nbg6617) and x86_64 (QEMU
and apu2).

1. https://www.python.org/dev/peps/pep-0373/

Ref: PR#1937
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Cc: Mathew McBride <matt@traverse.com.au>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 README                  |  2 +-
 include/prereq-build.mk | 15 +++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

Comments

Yangbo Lu June 19, 2019, 3:20 a.m. UTC | #1
Hi Petr,

> -----Original Message-----
> From: Petr Štetiar <ynezz@true.cz>
> Sent: 2019年6月18日 4:09
> To: openwrt-devel@lists.openwrt.org
> Cc: Petr Štetiar <ynezz@true.cz>; Y.b. Lu <yangbo.lu@nxp.com>; Mathew
> McBride <matt@traverse.com.au>
> Subject: [PATCH 5/6] build: switch to Python 3
> 
> This patch switches Python used in buildroot to Python 3 as Python 2.x series
> is going to be EOL relatively soon[1].
> 
>  "Being the last of the Python 2.x series, 2.7 will have an extended
>   period of maintenance. Specifically, 2.7 will receive bugfix support
>   until January 1, 2020. After the last release, 2.7 will receive no
>   support."
> 
> It seems like Python 3 is going to be needed in order to support Meson build
> system which has gained some traction recently.
> 
> Build tested on following targets:
> 
>  ath79/generic
>  imx6/generic
>  ipq40xx/generic
>  lantiq/xway
>  layerscape/armv7 (broken)
>  layerscape/armv8_32b (broken)
>  layerscape/armv8_64b (broken)
>  mvebu/cortexa72
>  ramips/mt7621
>  ramips/mt7620
>  sunxi/cortexa7
>  x86/64
> 
> Layerscape targets are unfortunately left broken as their ls-rcw firmware
> package uses Python 2 and converting it to Python 3 would take more then
> reasoanble amount of time (I've tried to fix it already) and would be better
> fixed by someone who can even run test it.

[Y.b. Lu] I created a pull request for ls-rcw to convert to python3. I compared the binaries generated with python2 and python3. Looked good.
Please help to review or cherry-pick if you need.
https://github.com/openwrt/openwrt/pull/2149


> 
> Run tested on ath79 (Archer C7 v5), ipq40xx (nbg6617) and x86_64 (QEMU
> and apu2).
> 
> 1.
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.p
> ython.org%2Fdev%2Fpeps%2Fpep-0373%2F&amp;data=02%7C01%7Cyangbo.
> lu%40nxp.com%7C8ea4f054b5be452b1f8808d6f35fa7af%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C1%7C636963989493552800&amp;sdata=mnt
> xb7ox6zgB2n%2B%2Fe07n%2Blhq%2FLqVAxaSgvTzCfb6YvE%3D&amp;reserve
> d=0
> 
> Ref: PR#1937
> Cc: Yangbo Lu <yangbo.lu@nxp.com>
> Cc: Mathew McBride <matt@traverse.com.au>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  README                  |  2 +-
>  include/prereq-build.mk | 15 +++++++++++----
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/README b/README
> index 55ca92af65f8..c867c1fa4da8 100644
> --- a/README
> +++ b/README
> @@ -11,7 +11,7 @@ To build your own firmware you need a Linux, BSD or
> MacOSX system (case  sensitive filesystem required). Cygwin is unsupported
> because of the lack  of a case sensitive file system.
> 
> -You need gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff,
> +You need gcc, binutils, bzip2, flex, python3.5+, perl, make, find,
> +grep, diff,
>  unzip, gawk, getopt, subversion, libz-dev and libc headers installed.
> 
>  1. Run "./scripts/feeds update -a" to obtain all the latest package definitions
> diff --git a/include/prereq-build.mk b/include/prereq-build.mk index
> f7da916f648c..c52ca719087c 100644
> --- a/include/prereq-build.mk
> +++ b/include/prereq-build.mk
> @@ -141,10 +141,17 @@ $(eval $(call SetupHostCommand,wget,Please
> install GNU 'wget', \  $(eval $(call SetupHostCommand,perl,Please install Perl
> 5.x, \
>  	perl --version | grep "perl.*v5"))
> 
> -$(eval $(call SetupHostCommand,python,Please install Python 2.x, \
> -	python2.7 -V 2>&1 | grep Python, \
> -	python2 -V 2>&1 | grep Python, \
> -	python -V 2>&1 | grep Python))
> +$(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
> +	python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
> +
> +$(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \
> +	python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> +	python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
> 
>  $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
>  	git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
> --
> 1.9.1
Petr Štetiar June 19, 2019, 8:07 a.m. UTC | #2
Y.b. Lu <yangbo.lu@nxp.com> [2019-06-19 03:20:43]:

Hi,

> >  ath79/generic
> >  imx6/generic
> >  ipq40xx/generic
> >  lantiq/xway
> >  layerscape/armv7 (broken)
> >  layerscape/armv8_32b (broken)
> >  layerscape/armv8_64b (broken)

thanks a lot for such quick response and the fix, layerscape builds fine now
with Python 3.

> >  mvebu/cortexa72
> >  ramips/mt7621
> >  ramips/mt7620
> >  sunxi/cortexa7
> >  x86/64
> > 
> > Layerscape targets are unfortunately left broken as their ls-rcw firmware
> > package uses Python 2 and converting it to Python 3 would take more then
> > reasoanble amount of time (I've tried to fix it already) and would be better
> > fixed by someone who can even run test it.
>
> [Y.b. Lu] I created a pull request for ls-rcw to convert to python3. I
> compared the binaries generated with python2 and python3. Looked good.
> Please help to review or cherry-pick if you need.
> https://github.com/openwrt/openwrt/pull/2149

I've cherry-picked it to my wip/python3 branch. Thanks.

-- ynezz
diff mbox series

Patch

diff --git a/README b/README
index 55ca92af65f8..c867c1fa4da8 100644
--- a/README
+++ b/README
@@ -11,7 +11,7 @@  To build your own firmware you need a Linux, BSD or MacOSX system (case
 sensitive filesystem required). Cygwin is unsupported because of the lack
 of a case sensitive file system.
 
-You need gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff,
+You need gcc, binutils, bzip2, flex, python3.5+, perl, make, find, grep, diff,
 unzip, gawk, getopt, subversion, libz-dev and libc headers installed.
 
 1. Run "./scripts/feeds update -a" to obtain all the latest package definitions
diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index f7da916f648c..c52ca719087c 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -141,10 +141,17 @@  $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
 	perl --version | grep "perl.*v5"))
 
-$(eval $(call SetupHostCommand,python,Please install Python 2.x, \
-	python2.7 -V 2>&1 | grep Python, \
-	python2 -V 2>&1 | grep Python, \
-	python -V 2>&1 | grep Python))
+$(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
+	python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
+
+$(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \
+	python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
+	python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
 
 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
 	git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))