waf: explicitly run waf under Python 3

Submitted by Ross Burton on Oct. 14, 2020, 11:26 a.m. | Patch ID: 177240

Details

Message ID 20201014112620.2244199-1-ross.burton@arm.com
State New
Headers show

Commit Message

Ross Burton Oct. 14, 2020, 11:26 a.m.
We don't assume Python 2 is on the host and don't expose an unversioned
python in HOSTTOOLS, but waf uses the unversion python binary.

Typically this is solved by patching waf (see the glmark2 recipe) but
this can be solved centrally by invoking python3 directly.  All wscripts
that needed Python 2 would have been fixed by now.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes/waf.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/waf.bbclass b/meta/classes/waf.bbclass
index 309f625a40..df6d4d53e8 100644
--- a/meta/classes/waf.bbclass
+++ b/meta/classes/waf.bbclass
@@ -42,7 +42,7 @@  python waf_preconfigure() {
     subsrcdir = d.getVar('S')
     wafbin = os.path.join(subsrcdir, 'waf')
     try:
-        result = subprocess.check_output([wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
+        result = subprocess.check_output(['python3', wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
         version = result.decode('utf-8').split()[1]
         if StrictVersion(version) >= StrictVersion("1.8.7"):
             d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}")
@@ -55,16 +55,16 @@  python waf_preconfigure() {
 do_configure[prefuncs] += "waf_preconfigure"
 
 waf_do_configure() {
-	(cd ${S} && ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
+	(cd ${S} && python3 ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
 }
 
 do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
 waf_do_compile()  {
-	(cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
+	(cd ${S} && python3 ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
 }
 
 waf_do_install() {
-	(cd ${S} && ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
+	(cd ${S} && python3 ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
 }
 
 EXPORT_FUNCTIONS do_configure do_compile do_install

Comments

Joshua Watt Oct. 14, 2020, 12:41 p.m.
On Wed, Oct 14, 2020, 6:26 AM Ross Burton <ross@burtonini.com> wrote:

> We don't assume Python 2 is on the host and don't expose an unversioned
> python in HOSTTOOLS, but waf uses the unversion python binary.
>
> Typically this is solved by patching waf (see the glmark2 recipe) but
> this can be solved centrally by invoking python3 directly.  All wscripts
> that needed Python 2 would have been fixed by now.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  meta/classes/waf.bbclass | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/waf.bbclass b/meta/classes/waf.bbclass
> index 309f625a40..df6d4d53e8 100644
> --- a/meta/classes/waf.bbclass
> +++ b/meta/classes/waf.bbclass
> @@ -42,7 +42,7 @@ python waf_preconfigure() {
>      subsrcdir = d.getVar('S')
>      wafbin = os.path.join(subsrcdir, 'waf')
>      try:
> -        result = subprocess.check_output([wafbin, '--version'],
> cwd=subsrcdir, stderr=subprocess.STDOUT)
> +        result = subprocess.check_output(['python3', wafbin,
> '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
>

This will break our internal usage... We still use waf 1 which runs under
python 2 only :(, although we are working on transitioning

         version = result.decode('utf-8').split()[1]
>          if StrictVersion(version) >= StrictVersion("1.8.7"):
>              d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir}
> --libdir=${libdir}")
> @@ -55,16 +55,16 @@ python waf_preconfigure() {
>  do_configure[prefuncs] += "waf_preconfigure"
>
>  waf_do_configure() {
> -       (cd ${S} && ./waf configure -o ${B} --prefix=${prefix}
> ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
> +       (cd ${S} && python3 ./waf configure -o ${B} --prefix=${prefix}
> ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
>  }
>
>  do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
>  waf_do_compile()  {
> -       (cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d,
> '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
> +       (cd ${S} && python3 ./waf build
> ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}
> ${EXTRA_OEWAF_BUILD})
>  }
>
>  waf_do_install() {
> -       (cd ${S} && ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
> +       (cd ${S} && python3 ./waf install --destdir=${D}
> ${EXTRA_OEWAF_INSTALL})
>  }
>
>  EXPORT_FUNCTIONS do_configure do_compile do_install
> --
> 2.25.1
>
>
> 
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#143331): https://lists.openembedded.org/g/openembedded-core/message/143331
Mute This Topic: https://lists.openembedded.org/mt/77503121/3617530
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-
Khem Raj Oct. 14, 2020, 9:01 p.m.
On Wed, Oct 14, 2020 at 5:41 AM Joshua Watt <JPEWhacker@gmail.com> wrote:
>
>
>
> On Wed, Oct 14, 2020, 6:26 AM Ross Burton <ross@burtonini.com> wrote:
>>
>> We don't assume Python 2 is on the host and don't expose an unversioned
>> python in HOSTTOOLS, but waf uses the unversion python binary.
>>
>> Typically this is solved by patching waf (see the glmark2 recipe) but
>> this can be solved centrally by invoking python3 directly.  All wscripts
>> that needed Python 2 would have been fixed by now.
>>
>> Signed-off-by: Ross Burton <ross.burton@arm.com>
>> ---
>>  meta/classes/waf.bbclass | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/meta/classes/waf.bbclass b/meta/classes/waf.bbclass
>> index 309f625a40..df6d4d53e8 100644
>> --- a/meta/classes/waf.bbclass
>> +++ b/meta/classes/waf.bbclass
>> @@ -42,7 +42,7 @@ python waf_preconfigure() {
>>      subsrcdir = d.getVar('S')
>>      wafbin = os.path.join(subsrcdir, 'waf')
>>      try:
>> -        result = subprocess.check_output([wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
>> +        result = subprocess.check_output(['python3', wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
>
>
> This will break our internal usage... We still use waf 1 which runs under python 2 only :(, although we are working on transitioning

this is for master and we have already said goodbye to python2 in
oe-core. perhaps reverse patching waf in your app might be an option ?

>
>>          version = result.decode('utf-8').split()[1]
>>          if StrictVersion(version) >= StrictVersion("1.8.7"):
>>              d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}")
>> @@ -55,16 +55,16 @@ python waf_preconfigure() {
>>  do_configure[prefuncs] += "waf_preconfigure"
>>
>>  waf_do_configure() {
>> -       (cd ${S} && ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
>> +       (cd ${S} && python3 ./waf configure -o ${B} --prefix=${prefix} ${WAF_EXTRA_CONF} ${EXTRA_OECONF})
>>  }
>>
>>  do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
>>  waf_do_compile()  {
>> -       (cd ${S} && ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
>> +       (cd ${S} && python3 ./waf build ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)} ${EXTRA_OEWAF_BUILD})
>>  }
>>
>>  waf_do_install() {
>> -       (cd ${S} && ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
>> +       (cd ${S} && python3 ./waf install --destdir=${D} ${EXTRA_OEWAF_INSTALL})
>>  }
>>
>>  EXPORT_FUNCTIONS do_configure do_compile do_install
>> --
>> 2.25.1
>>
>>
>>
>>
>
> 
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#143334): https://lists.openembedded.org/g/openembedded-core/message/143334
Mute This Topic: https://lists.openembedded.org/mt/77503121/3617530
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-