diff mbox series

[RFC] package/python-mako: build host-python-mako as python3 module for mesa3d build.

Message ID 20190413164606.25700-1-romain.naour@smile.fr
State Changes Requested
Headers show
Series [RFC] package/python-mako: build host-python-mako as python3 module for mesa3d build. | expand

Commit Message

Romain Naour April 13, 2019, 4:46 p.m. UTC
Since a long time, it was not possible to build mesa3d from the git
repository due to the missing dependency on host-python-mako package
in mesa3d package.

python-mako module is used by a python script
ir_expression_operation.py to build the header file
ir_expression_operation_constant.h.

Hopefully when building mesa3d from a tarball release using the
autotools build system, this header is alreay generated and the build
continue.

But we are switching mesa3d package to meson build system that check
unconditionnaly if the mako module for python3 interpreter is present.

Even by removing this check, the meson build system call
ir_expression_operation.py script even if
ir_expression_operation_constant.h is already generated.

The problem with host-python-mako and mesa3d is that we need to build
mako module for python3 interpreter. Adding host-python-mako as mesa3d
dependency is not enough since it can be build as host python2 module
when BR2_PACKAGE_PYTHON3 is not selected for the target.

But adding python3 on the target in order to have a python3 module
on the host is not nice.

To build host-python-mako as python3 module we can add this line
in pyhon-mako package:
HOST_PYTHON_MAKO_NEEDS_HOST_PYTHON = python3

But python mako is not available anymore for python2 interpreter.

The problem is more global, how can we build the same python
module for python2 and/or python3 on the host ?

Mako module is also used by gnuradio build system and building
this module for python3 for mesa3d can eventually break the build of
gnuradio when the python interpreter on the host is python2
(to be tested).

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Asaf Kahlon <asafka7@gmail.com>
Cc: Bernd Kuhls <bernd.kuhls@t-online.de>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
---
 package/python-mako/python-mako.mk | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Thomas Petazzoni April 13, 2019, 4:54 p.m. UTC | #1
Hello Romain,

On Sat, 13 Apr 2019 18:46:06 +0200
Romain Naour <romain.naour@smile.fr> wrote:

> But adding python3 on the target in order to have a python3 module
> on the host is not nice.
> 
> To build host-python-mako as python3 module we can add this line
> in pyhon-mako package:
> HOST_PYTHON_MAKO_NEEDS_HOST_PYTHON = python3
> 
> But python mako is not available anymore for python2 interpreter.
> 
> The problem is more global, how can we build the same python
> module for python2 and/or python3 on the host ?

We can't :-)

> Mako module is also used by gnuradio build system and building
> this module for python3 for mesa3d can eventually break the build of
> gnuradio when the python interpreter on the host is python2
> (to be tested).

Indeed, your patch would break situations where mesa3d is enabled, but
another package needs host-python-mako for python2 (and not python3).

We solved this problem for python-setuptools by having
host-python-setuptools and host-python3-setuptools as separate
packages. It's not great, but we don't have any other good solution for
this at the moment I believe.

Alternatively, perhaps for host Python modules we should always install
them for both host-python and host-python3 (if both are enabled, of
course). The gotcha is that since we don't have any Config.in options
for host packages, how can we know if host-python and/or host-python3
are enabled ?

Thomas
Romain Naour April 13, 2019, 5:10 p.m. UTC | #2
Hi Thomas,

Le 13/04/2019 à 18:54, Thomas Petazzoni a écrit :
> Hello Romain,
> 
> On Sat, 13 Apr 2019 18:46:06 +0200
> Romain Naour <romain.naour@smile.fr> wrote:
> 
>> But adding python3 on the target in order to have a python3 module
>> on the host is not nice.
>>
>> To build host-python-mako as python3 module we can add this line
>> in pyhon-mako package:
>> HOST_PYTHON_MAKO_NEEDS_HOST_PYTHON = python3
>>
>> But python mako is not available anymore for python2 interpreter.
>>
>> The problem is more global, how can we build the same python
>> module for python2 and/or python3 on the host ?
> 
> We can't :-)

My issue would be solved if we can do that :p

> 
>> Mako module is also used by gnuradio build system and building
>> this module for python3 for mesa3d can eventually break the build of
>> gnuradio when the python interpreter on the host is python2
>> (to be tested).
> 
> Indeed, your patch would break situations where mesa3d is enabled, but
> another package needs host-python-mako for python2 (and not python3).

Indeed it break gnuradio:

-- Configuring VOLK support...
-- Build type set to Release.
-- Found PythonInterp: output/host/bin/python2 (found suitable version "2.7.15",
minimum required is "2")
Arnout Vandecappelle April 13, 2019, 6:31 p.m. UTC | #3
On 13/04/2019 18:54, Thomas Petazzoni wrote:
> Alternatively, perhaps for host Python modules we should always install
> them for both host-python and host-python3 (if both are enabled, of
> course). The gotcha is that since we don't have any Config.in options
> for host packages, how can we know if host-python and/or host-python3
> are enabled ?

 We decided in February that having Config.in.host for all packages would add
too much complexity and confusion. We could, however, still do it for python/3
(just like we already have a few blind host package configs). By my count, 52
packages would have to be updated to select BR2_PACKAGE_HOST_PYTHON{,3}. That is
borderline doable, I think.

 The tricky part is detecting when we fail to do the select.

 Regards,
 Arnout
Romain Naour April 14, 2019, 8:24 p.m. UTC | #4
Hi Thomas, Arnout, All,

Le 13/04/2019 à 18:46, Romain Naour a écrit :
> Since a long time, it was not possible to build mesa3d from the git
> repository due to the missing dependency on host-python-mako package
> in mesa3d package.
> 
> python-mako module is used by a python script
> ir_expression_operation.py to build the header file
> ir_expression_operation_constant.h.
> 
> Hopefully when building mesa3d from a tarball release using the
> autotools build system, this header is alreay generated and the build
> continue.
> 
> But we are switching mesa3d package to meson build system that check
> unconditionnaly if the mako module for python3 interpreter is present.
> 
> Even by removing this check, the meson build system call
> ir_expression_operation.py script even if
> ir_expression_operation_constant.h is already generated.
> 
> The problem with host-python-mako and mesa3d is that we need to build
> mako module for python3 interpreter. Adding host-python-mako as mesa3d
> dependency is not enough since it can be build as host python2 module
> when BR2_PACKAGE_PYTHON3 is not selected for the target.
> 
> But adding python3 on the target in order to have a python3 module
> on the host is not nice.
> 
> To build host-python-mako as python3 module we can add this line
> in pyhon-mako package:
> HOST_PYTHON_MAKO_NEEDS_HOST_PYTHON = python3
> 
> But python mako is not available anymore for python2 interpreter.
> 
> The problem is more global, how can we build the same python
> module for python2 and/or python3 on the host ?
> 
> Mako module is also used by gnuradio build system and building
> this module for python3 for mesa3d can eventually break the build of
> gnuradio when the python interpreter on the host is python2
> (to be tested).
> 
> Signed-off-by: Romain Naour <romain.naour@smile.fr>
> Cc: Asaf Kahlon <asafka7@gmail.com>
> Cc: Bernd Kuhls <bernd.kuhls@t-online.de>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Yegor Yefremov <yegorslists@googlemail.com>
> ---

Actually it's easier to hack the mesa's meson build system than hacking the
python infra...

I have a small patch for mesa that allow to use generated files present in the
release archive (like autotools buils system does).

Best regards,
Romain
diff mbox series

Patch

diff --git a/package/python-mako/python-mako.mk b/package/python-mako/python-mako.mk
index 0d06dc4986..710e4bbe32 100644
--- a/package/python-mako/python-mako.mk
+++ b/package/python-mako/python-mako.mk
@@ -14,5 +14,11 @@  PYTHON_MAKO_LICENSE_FILES = LICENSE
 # In host build, setup.py tries to download markupsafe if it is not installed
 HOST_PYTHON_MAKO_DEPENDENCIES = host-python-markupsafe
 
+# mesa3d python script use python-mako module only for python3.
+# So, build python-mako as python3 module.
+ifeq ($(BR2_PACKAGE_MESA3D),y)
+HOST_PYTHON_MAKO_NEEDS_HOST_PYTHON = python3
+endif
+
 $(eval $(python-package))
 $(eval $(host-python-package))