Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgpiod_1.3 fails when building Python bindings (cannot find Python.h) #140

Closed
harrymander opened this issue Aug 15, 2019 · 10 comments
Closed

Comments

@harrymander
Copy link

Building libgpiod 1.3 with the Python bindings enabled on warrior. do_compile fails with this error:

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>
@kraj
Copy link
Contributor

kraj commented Aug 15, 2019

@HarryManderTait do have Python.h in recipe staging sysroot ?

@harrymander
Copy link
Author

harrymander commented Aug 15, 2019

@kraj Yes: under recipe-sysroot/usr/include/python3.7m/Python.h

@kraj
Copy link
Contributor

kraj commented Aug 15, 2019

OK I think this could be a missing pkgconfing file or something, lets see if we can reproduce it

@harrymander
Copy link
Author

harrymander commented Aug 15, 2019

The issue seems to be from the conditional inherit in the recipe file. The python3native class wasn't being inherited because the inline Python function is expanded before python3 is appended to PACKAGECONFIGS. See https://www.yoctoproject.org/docs/2.7/mega-manual/mega-manual.html#inherit-directive:

An advantage with the inherit directive as compared to both the include and require directives is that you can inherit class files conditionally. You can accomplish this by using a variable expression after the inherit statement. Here is an example:
inherit ${VARNAME}
If VARNAME is going to be set, it needs to be set before the inherit statement is parsed. One way to achieve a conditional inherit in this case is to use overrides:

Removing the conditional inherit and just inheriting python3native worked for me:

--- a/meta-oe/recipes-support/libgpiod/libgpiod_1.3.bb
+++ b/meta-oe/recipes-support/libgpiod/libgpiod_1.3.bb
@@ -9,7 +9,7 @@ PACKAGECONFIG[cxx] = "--enable-bindings-cxx,--disable-bindings-cxx"
 PACKAGECONFIG[tests] = "--enable-tests --enable-install-tests,--disable-tests --disable-install-tests,kmod udev"
 
 PACKAGECONFIG[python3] = "--enable-bindings-python,--disable-bindings-python,python3"
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3native', '', d)}
+inherit python3native
 
 PACKAGES =+ "${PN}-python"
 FILES_${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"

@harrymander
Copy link
Author

Not sure if this is the best way since python3native is being inherited even if the Python bindings aren't used. Perhaps my method of enabling the bindings is wrong? I am doing it by adding libgpiod_%.bbappend in a custom layer:

# recipes-support/libgpiod/libgpiod_%.bbappend
PACKAGECONFIG_append = " python3"

@kraj
Copy link
Contributor

kraj commented Aug 17, 2019

what you are doing is okay. We need to check if we can disable python during build or do we have to always build it and then maybe package it up separately.

@kraj
Copy link
Contributor

kraj commented Aug 28, 2019

@HarryManderTait The problem surfaces when your bbappend is doing _append operation. So I think the correct way to handle this is that we add python3 to default packageconfigs and then someone who does not need python3 enabled can do PACKAGECONFIG_remove = "python3" in their bbappend

I have posted a fix here [1], which should help address this issue, please try it in your case and then request a backport of it to warrior

[1] https://patchwork.openembedded.org/patch/164345/

halstead pushed a commit that referenced this issue Aug 28, 2019
this recipe inherits python3native class conditionally, this condition
depends on a given packageconfig, however inherit ${VAR} syntax requires
VAR to be evaluated before inheriting it, therefore if someone appends
python3 to packageconfig via a bbappend, then the packageconfig will
become effective and add --enable-bindings-python to configure but
inherit wont evaluate correctly since the expression adding to
packageconfig

PACKAGECONFIG_append = " python3"

will be coming _after_ the inherit, and the builds will fail e.g.

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>

This patch inverts the logic, meaning if someone has to disable python3
bindings should write a bbappend e.g.

PACKAGECONFIG_remove = "python3"

This will still mean that python3native will be inherited but the
effective configure option will be --disable-bindings-python and that
will do the right thing

See. #140

Signed-off-by: Khem Raj <raj.khem@gmail.com>
@harrymander
Copy link
Author

@kraj according to your patch python3native always be inherited. So why not just inherit it unconditionally and keep Python out of the default packageconfigs?

@kraj
Copy link
Contributor

kraj commented Aug 28, 2019

I think its fine to change defaults since the bindings go into the package of their own anyway,

@harrymander
Copy link
Author

Patch works fine! Thanks.

kraj added a commit to YoeDistro/meta-openembedded that referenced this issue Aug 28, 2019
this recipe inherits python3native class conditionally, this condition
depends on a given packageconfig, however inherit ${VAR} syntax requires
VAR to be evaluated before inheriting it, therefore if someone appends
python3 to packageconfig via a bbappend, then the packageconfig will
become effective and add --enable-bindings-python to configure but
inherit wont evaluate correctly since the expression adding to
packageconfig

PACKAGECONFIG_append = " python3"

will be coming _after_ the inherit, and the builds will fail e.g.

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>

This will still mean that python3native is always inherited but the
effective configure option will be --disable-bindings-python and that
will do the right thing

See. openembedded#140

Signed-off-by: Khem Raj <raj.khem@gmail.com>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/meta-openembedded that referenced this issue Sep 5, 2019
Source: meta-openembedded
MR: 00000
Type: Integration
Disposition: Merged from meta-openembedded
ChangeID: 98625eb
Description:

this recipe inherits python3native class conditionally, this condition
depends on a given packageconfig, however inherit ${VAR} syntax requires
VAR to be evaluated before inheriting it, therefore if someone appends
python3 to packageconfig via a bbappend, then the packageconfig will
become effective and add --enable-bindings-python to configure but
inherit wont evaluate correctly since the expression adding to
packageconfig

PACKAGECONFIG_append = " python3"

will be coming _after_ the inherit, and the builds will fail e.g.

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>

This will still mean that python3native is always inherited but the
effective configure option will be --disable-bindings-python and that
will do the right thing

See. openembedded#140

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Jeremy Puhlman <jpuhlman@mvista.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Mar 14, 2022
- Change branch name master -> main according to upstream repository.
- Update 2.0.15 -> 2.0.16. Changelog:

    1df82b9 Add param traits for CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM (openembedded#165)
    814e7b2 update the C++ bindings code example (openembedded#151)
    6d833a5 Update opencl.hpp: Add CL_DEVICE_BOARD_NAME_AMD (openembedded#160)
    25ad589 Added missing definitions for deprecated prefixes and suffixes for version 2.2 (openembedded#159)
    21a34b0 Test two additional defines and update descriptions in header (openembedded#147)
    ff7318c Fix cl::enqueueMapSVM for cl::vector and cl::pointer (openembedded#145)
    30d4219 Test most of the possible defines (openembedded#140)
    63d9e41 Fix unreasonable error handling in opencl.hpp (openembedded#139)
    0198c41 Add support for cl_khr_integer_dot_product v2 (openembedded#141)
    8df6c8f Transition CI to Github Actions (openembedded#142)

Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Mar 14, 2022
- Change branch name master -> main according to upstream repository.
- Update 2.0.15 -> 2.0.16. Changelog:

    1df82b9 Add param traits for CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM (openembedded#165)
    814e7b2 update the C++ bindings code example (openembedded#151)
    6d833a5 Update opencl.hpp: Add CL_DEVICE_BOARD_NAME_AMD (openembedded#160)
    25ad589 Added missing definitions for deprecated prefixes and suffixes for version 2.2 (openembedded#159)
    21a34b0 Test two additional defines and update descriptions in header (openembedded#147)
    ff7318c Fix cl::enqueueMapSVM for cl::vector and cl::pointer (openembedded#145)
    30d4219 Test most of the possible defines (openembedded#140)
    63d9e41 Fix unreasonable error handling in opencl.hpp (openembedded#139)
    0198c41 Add support for cl_khr_integer_dot_product v2 (openembedded#141)
    8df6c8f Transition CI to Github Actions (openembedded#142)

Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Mar 14, 2022
- Change branch name master -> main according to upstream repository.
- Update 2.0.15 -> 2.0.16. Changelog:

    1df82b9 Add param traits for CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM (openembedded#165)
    814e7b2 update the C++ bindings code example (openembedded#151)
    6d833a5 Update opencl.hpp: Add CL_DEVICE_BOARD_NAME_AMD (openembedded#160)
    25ad589 Added missing definitions for deprecated prefixes and suffixes for version 2.2 (openembedded#159)
    21a34b0 Test two additional defines and update descriptions in header (openembedded#147)
    ff7318c Fix cl::enqueueMapSVM for cl::vector and cl::pointer (openembedded#145)
    30d4219 Test most of the possible defines (openembedded#140)
    63d9e41 Fix unreasonable error handling in opencl.hpp (openembedded#139)
    0198c41 Add support for cl_khr_integer_dot_product v2 (openembedded#141)
    8df6c8f Transition CI to Github Actions (openembedded#142)

Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jun 29, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jun 29, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
halstead pushed a commit that referenced this issue Jun 29, 2022
Changelog:
=========
   add support for Python 3.11 PR #142
   do not install tests PR #143
   fix packaging for latest setuptools PR #140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jun 30, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jun 30, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jun 30, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Jul 1, 2022
Changelog:
=========
   add support for Python 3.11 PR openembedded#142
   do not install tests PR openembedded#143
   fix packaging for latest setuptools PR openembedded#140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
halstead pushed a commit that referenced this issue Jul 2, 2022
Changelog:
=========
   add support for Python 3.11 PR #142
   do not install tests PR #143
   fix packaging for latest setuptools PR #140

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
this recipe inherits python3native class conditionally, this condition
depends on a given packageconfig, however inherit ${VAR} syntax requires
VAR to be evaluated before inheriting it, therefore if someone appends
python3 to packageconfig via a bbappend, then the packageconfig will
become effective and add --enable-bindings-python to configure but
inherit wont evaluate correctly since the expression adding to
packageconfig

PACKAGECONFIG_append = " python3"

will be coming _after_ the inherit, and the builds will fail e.g.

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>

This will still mean that python3native is always inherited but the
effective configure option will be --disable-bindings-python and that
will do the right thing

See. openembedded/meta-openembedded#140

Signed-off-by: Khem Raj <raj.khem@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
this recipe inherits python3native class conditionally, this condition
depends on a given packageconfig, however inherit ${VAR} syntax requires
VAR to be evaluated before inheriting it, therefore if someone appends
python3 to packageconfig via a bbappend, then the packageconfig will
become effective and add --enable-bindings-python to configure but
inherit wont evaluate correctly since the expression adding to
packageconfig

PACKAGECONFIG_append = " python3"

will be coming _after_ the inherit, and the builds will fail e.g.

| ../../../libgpiod-1.3/bindings/python/gpiodmodule.c:8:10: fatal error: Python.h: No such file or directory
|  #include <Python.h>

This will still mean that python3native is always inherited but the
effective configure option will be --disable-bindings-python and that
will do the right thing

See. openembedded/meta-openembedded#140

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants