Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2] perf: change dependencies on python to python3
@ 2019-08-29  2:14 bruce.ashfield
  2019-08-29  3:20 ` Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: bruce.ashfield @ 2019-08-29  2:14 UTC (permalink / raw)
  To: richard.purdie; +Cc: openembedded-core

From: Bruce Ashfield <bruce.ashfield@gmail.com>

The upstream kernel can now handle python3 for the perf scripts, coupled
with the impending EOL of python2, we switch the dependencies in perf
(scripting) to python3.

Outside of dependency changes, we also pass the following two variables
to the perf build: PYTHON=python3 PYTHON_CONFIG=python3-config. To
ensure that our python3 components are used.

For configurations that disable perf scripting, there is no change in
behaviour.

[YOCTO #13358]

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---

v2:
  - tested against 4.19, 5.0 and 5.2+
  - broadened search path for scripts
  - added /usr/bin/python to the fixup list

 meta/recipes-kernel/perf/perf.bb | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index 4e603f1a32..af0410c88d 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -13,7 +13,7 @@ PR = "r9"
 
 PACKAGECONFIG ??= "scripting tui libunwind"
 PACKAGECONFIG[dwarf] = ",NO_DWARF=1"
-PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
+PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python3"
 # gui support was added with kernel 3.6.35
 # since 3.10 libnewt was replaced by slang
 # to cover a wide range of kernel we add both dependencies
@@ -44,8 +44,8 @@ PROVIDES = "virtual/perf"
 inherit linux-kernel-base kernel-arch manpages
 
 # needed for building the tools/perf Python bindings
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'pythonnative', '', d)}
-inherit python-dir
+inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'python3native', '', d)}
+inherit python3-dir
 export PYTHON_SITEPACKAGES_DIR
 
 #kernel 3.1+ supports WERROR to disable warnings as errors
@@ -94,6 +94,7 @@ EXTRA_OEMAKE += "\
     'sharedir=${@os.path.relpath(datadir, prefix)}' \
     'mandir=${@os.path.relpath(mandir, prefix)}' \
     'infodir=${@os.path.relpath(infodir, prefix)}' \
+    ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \
 "
 
 # During do_configure, we might run a 'make clean'. That often breaks
@@ -132,7 +133,7 @@ do_install() {
 	oe_runmake install
 	# we are checking for this make target to be compatible with older perf versions
 	if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
-		oe_runmake DESTDIR=${D} install-python_ext
+	    oe_runmake DESTDIR=${D} install-python_ext
 	fi
 }
 
@@ -232,8 +233,10 @@ do_configure_prepend () {
     fi
 
     # use /usr/bin/env instead of version specific python
-    for s in `find ${S}/tools/perf/scripts/python/ -name '*.py'`; do
-        sed -i 's,/usr/bin/python2,/usr/bin/env python,' "${s}"
+    for s in `find ${S}/tools/perf/ -name '*.py'`; do
+        sed -i 's,/usr/bin/python,/usr/bin/env python3,' "${s}"
+        sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "${s}"
+        sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "${s}"
     done
 
     # unistd.h can be out of sync between libc-headers and the captured version in the perf source
@@ -252,9 +255,9 @@ PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
 
 RDEPENDS_${PN} += "elfutils bash"
 RDEPENDS_${PN}-archive =+ "bash"
-RDEPENDS_${PN}-python =+ "bash python python-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}"
+RDEPENDS_${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python3', '', d)}"
 RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
-RDEPENDS_${PN}-tests =+ "python"
+RDEPENDS_${PN}-tests =+ "python3"
 
 RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
 RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] perf: change dependencies on python to python3
  2019-08-29  2:14 [PATCH v2] perf: change dependencies on python to python3 bruce.ashfield
@ 2019-08-29  3:20 ` Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2019-08-29  3:20 UTC (permalink / raw)
  To: Richard Purdie; +Cc: Patches and discussions about the oe-core layer

On Wed, Aug 28, 2019 at 10:14 PM <bruce.ashfield@gmail.com> wrote:
>
> From: Bruce Ashfield <bruce.ashfield@gmail.com>
>
> The upstream kernel can now handle python3 for the perf scripts, coupled
> with the impending EOL of python2, we switch the dependencies in perf
> (scripting) to python3.
>
> Outside of dependency changes, we also pass the following two variables
> to the perf build: PYTHON=python3 PYTHON_CONFIG=python3-config. To
> ensure that our python3 components are used.
>
> For configurations that disable perf scripting, there is no change in
> behaviour.
>
> [YOCTO #13358]
>
> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
> ---
>
> v2:
>   - tested against 4.19, 5.0 and 5.2+
>   - broadened search path for scripts
>   - added /usr/bin/python to the fixup list

Also, if a meta-python2 is created, we can do a perf variant that
depends on python2 so older kernels (that can't be patched) can still
use perf scripting if they want. But I'm betting the number of
users/kernels is quite small, so it may just be better as an "on
demand" thing.

Cheers,

Bruce

>
>  meta/recipes-kernel/perf/perf.bb | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
> index 4e603f1a32..af0410c88d 100644
> --- a/meta/recipes-kernel/perf/perf.bb
> +++ b/meta/recipes-kernel/perf/perf.bb
> @@ -13,7 +13,7 @@ PR = "r9"
>
>  PACKAGECONFIG ??= "scripting tui libunwind"
>  PACKAGECONFIG[dwarf] = ",NO_DWARF=1"
> -PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
> +PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python3"
>  # gui support was added with kernel 3.6.35
>  # since 3.10 libnewt was replaced by slang
>  # to cover a wide range of kernel we add both dependencies
> @@ -44,8 +44,8 @@ PROVIDES = "virtual/perf"
>  inherit linux-kernel-base kernel-arch manpages
>
>  # needed for building the tools/perf Python bindings
> -inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'pythonnative', '', d)}
> -inherit python-dir
> +inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'python3native', '', d)}
> +inherit python3-dir
>  export PYTHON_SITEPACKAGES_DIR
>
>  #kernel 3.1+ supports WERROR to disable warnings as errors
> @@ -94,6 +94,7 @@ EXTRA_OEMAKE += "\
>      'sharedir=${@os.path.relpath(datadir, prefix)}' \
>      'mandir=${@os.path.relpath(mandir, prefix)}' \
>      'infodir=${@os.path.relpath(infodir, prefix)}' \
> +    ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \
>  "
>
>  # During do_configure, we might run a 'make clean'. That often breaks
> @@ -132,7 +133,7 @@ do_install() {
>         oe_runmake install
>         # we are checking for this make target to be compatible with older perf versions
>         if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
> -               oe_runmake DESTDIR=${D} install-python_ext
> +           oe_runmake DESTDIR=${D} install-python_ext
>         fi
>  }
>
> @@ -232,8 +233,10 @@ do_configure_prepend () {
>      fi
>
>      # use /usr/bin/env instead of version specific python
> -    for s in `find ${S}/tools/perf/scripts/python/ -name '*.py'`; do
> -        sed -i 's,/usr/bin/python2,/usr/bin/env python,' "${s}"
> +    for s in `find ${S}/tools/perf/ -name '*.py'`; do
> +        sed -i 's,/usr/bin/python,/usr/bin/env python3,' "${s}"
> +        sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "${s}"
> +        sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "${s}"
>      done
>
>      # unistd.h can be out of sync between libc-headers and the captured version in the perf source
> @@ -252,9 +255,9 @@ PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
>
>  RDEPENDS_${PN} += "elfutils bash"
>  RDEPENDS_${PN}-archive =+ "bash"
> -RDEPENDS_${PN}-python =+ "bash python python-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}"
> +RDEPENDS_${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python3', '', d)}"
>  RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
> -RDEPENDS_${PN}-tests =+ "python"
> +RDEPENDS_${PN}-tests =+ "python3"
>
>  RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
>  RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
> --
> 2.19.1
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-29  3:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-29  2:14 [PATCH v2] perf: change dependencies on python to python3 bruce.ashfield
2019-08-29  3:20 ` Bruce Ashfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox