diff mbox series

[v2,2/2] package/qemu: add host-python as an explicit dependency

Message ID 20191111213154.19409-2-avraham.shukron@gmail.com
State Changes Requested
Headers show
Series [v2,1/2] package/ninja: invoke python3 explicitly to configure the package | expand

Commit Message

Avi Shukron Nov. 11, 2019, 9:31 p.m. UTC
qemu requires python in its configre script. Yet host-python was
not listed as one of the package's dependencies. If no other package
requested host-python, then configuring this package will fail since
it won't find any executable named python in the host dir.

In order to reproduce this issue you must not have python2 installed
on your host machine.

Signed-off-by: Avi Shukron <avraham.shukron@gmail.com>
---
 package/qemu/qemu.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni Nov. 12, 2019, 9:05 p.m. UTC | #1
On Mon, 11 Nov 2019 23:31:46 +0200
Avi Shukron <avraham.shukron@gmail.com> wrote:

> qemu requires python in its configre script. Yet host-python was
> not listed as one of the package's dependencies. If no other package
> requested host-python, then configuring this package will fail since
> it won't find any executable named python in the host dir.
> 
> In order to reproduce this issue you must not have python2 installed
> on your host machine.
> 
> Signed-off-by: Avi Shukron <avraham.shukron@gmail.com>

qemu needs python 2 *or* python 3, so we can do something like this:

QEMU_DEPENDENCIES = host-pkgconf libglib2 zlib pixman $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)

This way, if you have Python 3.x enabled for the target (and therefore
you are already building host-python3), it will use host-python3.

Could you test this in a configuration that has BR2_PACKAGE_QEMU=y and
BR2_PACKAGE_PYTHON3=y, and check it works properly ?

Thanks!

Thomas
Avi Shukron Nov. 13, 2019, 8:22 p.m. UTC | #2
On Tue, Nov 12, 2019 at 11:05 PM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:
>
>
> qemu needs python 2 *or* python 3, so we can do something like this:
>
> QEMU_DEPENDENCIES = host-pkgconf libglib2 zlib pixman $(if
$(BR2_PACKAGE_PYTHON3),host-python3,host-python)
>
> This way, if you have Python 3.x enabled for the target (and therefore
> you are already building host-python3), it will use host-python3.
>
> Could you test this in a configuration that has BR2_PACKAGE_QEMU=y and
> BR2_PACKAGE_PYTHON3=y, and check it works properly ?

Your suggestion works. If python3 is selected - host-python3 is used.
BUT - host-qemu also depends on host-libglib2 which depends on host-meson
which depends on python3,
so even if you **don't** select python3 you end up with host-python3
because of meson, and also
host-python because now host-qemu directly depends on it. Attached a
dependency graph depicting
the scenario.

So - since host-python3 will be used anyway - I suggest we just depend on
it exclusively.
What do you think?

BTW - I'm pretty sure that there aren't really so many packages that truly
depends on **host**-python2 (except maybe python2 itself)
So in general I think it could be a good idea to just replace **all**
host-python with host-python3 (again - except python2 itself) and
just see what happens.
It might just work.

Avi.
Thomas Petazzoni Nov. 15, 2019, 9:08 p.m. UTC | #3
Hello,

On Wed, 13 Nov 2019 22:22:00 +0200
Avraham Shukron <avraham.shukron@gmail.com> wrote:

> Your suggestion works. If python3 is selected - host-python3 is used.
> BUT - host-qemu also depends on host-libglib2 which depends on host-meson
> which depends on python3,

True. But then, how did you get build issues when building qemu ? I
mean, your v3 in fact doesn't do anything really: host-python3 was
already built as one of the dependencies of qemu, through libglib2. So
how did you get issues ?

> BTW - I'm pretty sure that there aren't really so many packages that truly
> depends on **host**-python2 (except maybe python2 itself)
> So in general I think it could be a good idea to just replace **all**
> host-python with host-python3 (again - except python2 itself) and
> just see what happens.

We discussed this at the latest Buildroot Developers meeting, you can
see some notes in "Python 2 deprecation" at
https://bimestriel.framapad.org/p/buildroot-elce-2019-meeting. We
welcome contributions in this area.

Thanks,

Thomas
Avi Shukron Nov. 15, 2019, 10:04 p.m. UTC | #4
On Fri, Nov 15, 2019 at 11:08 PM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:
> True. But then, how did you get build issues when building qemu ? I
> mean, your v3 in fact doesn't do anything really: host-python3 was
> already built as one of the dependencies of qemu, through libglib2. So
> how did you get issues ?

Damn, you are right, host-python3 won't work.
I've managed to build it only because I had host-python(2) still installed
in my host dir during my experiments.
A clean build still fails because there is no "python" executable in the
host dir unless you build any python for
the target.

So we only left with your suggestion, that in the best case (python3 is
selected for the target)
will only build host-python3.
Any other case will force both host-python and host-python3 to be built.

So I'll re-submit with your $(if..) solution soon.

> We discussed this at the latest Buildroot Developers meeting, you can
> see some notes in "Python 2 deprecation" at
> https://bimestriel.framapad.org/p/buildroot-elce-2019-meeting. We
> welcome contributions in this area.

Great, I'll try to put  some work into that.
Thomas Petazzoni Nov. 15, 2019, 10:51 p.m. UTC | #5
Hello,

On Sat, 16 Nov 2019 00:04:59 +0200
Avraham Shukron <avraham.shukron@gmail.com> wrote:

> Damn, you are right, host-python3 won't work.
> I've managed to build it only because I had host-python(2) still installed
> in my host dir during my experiments.
> A clean build still fails because there is no "python" executable in the
> host dir unless you build any python for
> the target.
> 
> So we only left with your suggestion, that in the best case (python3 is
> selected for the target)
> will only build host-python3.
> Any other case will force both host-python and host-python3 to be built.
> 
> So I'll re-submit with your $(if..) solution soon.

So, the qemu build system requires having an interpreter called "python" ?

Thomas
Avi Shukron Nov. 16, 2019, 11:59 a.m. UTC | #6
On Sat, Nov 16, 2019 at 12:51 AM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:

> So, the qemu build system requires having an interpreter called "python" ?
>

Yes.
But now I see that I can pass --python to the configure script with
the path to the interpreter, so I can simply pass $(HOST_DIR)/bin/python3
and
be done with it...
One less package depending on host-python(2).
diff mbox series

Patch

diff --git a/package/qemu/qemu.mk b/package/qemu/qemu.mk
index a91f9d3eeb..00d413b68d 100644
--- a/package/qemu/qemu.mk
+++ b/package/qemu/qemu.mk
@@ -21,7 +21,7 @@  QEMU_LICENSE_FILES = COPYING COPYING.LIB
 #-------------------------------------------------------------
 # Target-qemu
 
-QEMU_DEPENDENCIES = host-pkgconf libglib2 zlib pixman
+QEMU_DEPENDENCIES = host-pkgconf libglib2 zlib pixman host-python
 
 # Need the LIBS variable because librt and libm are
 # not automatically pulled. :-(
@@ -182,7 +182,7 @@  $(eval $(generic-package))
 #-------------------------------------------------------------
 # Host-qemu
 
-HOST_QEMU_DEPENDENCIES = host-pkgconf host-zlib host-libglib2 host-pixman
+HOST_QEMU_DEPENDENCIES = host-pkgconf host-zlib host-libglib2 host-pixman host-python
 
 #       BR ARCH         qemu
 #       -------         ----