On 2023-05-03 19:30, Tim Orling wrote:
I am working on an upgrade from 39.0.2 to 40.0.2 for python3-cryptography:
https://git.yoctoproject.org/poky-contrib/log/?h=timo/python3-cryptography_40.0.2

The patch at the tip of HEAD is perhaps not needed, as the compiling of `openssl-sys` was not the problem. We might need tweaks to not vendor OpenSSL, but I do not think this is the root of the problem right now.

The issue I am struggling with is "Python.h" is not being found:
|   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
|   CRATE_CC_NO_DEFAULTS = Some("1")
|   Info: default compiler flags are disabled
|   cargo:rerun-if-env-changed=CC_x86_64-poky-linux-gnu
|   CC_x86_64-poky-linux-gnu = None
|   cargo:rerun-if-env-changed=CC_x86_64_poky_linux_gnu
|   CC_x86_64_poky_linux_gnu = None
|   cargo:rerun-if-env-changed=TARGET_CC
|   TARGET_CC = None
|   cargo:rerun-if-env-changed=CC
|   CC = Some("x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot")
|   cargo:rerun-if-env-changed=CFLAGS_x86_64-poky-linux-gnu
|   CFLAGS_x86_64-poky-linux-gnu = None
|   cargo:rerun-if-env-changed=CFLAGS_x86_64_poky_linux_gnu
|   CFLAGS_x86_64_poky_linux_gnu = None
|   cargo:rerun-if-env-changed=TARGET_CFLAGS
|   TARGET_CFLAGS = None
|   cargo:rerun-if-env-changed=CFLAGS
|   CFLAGS = Some(" -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/cryptography-40.0.2=/usr/src/debug/python3-cryptography/40.0.2-r0  -fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/cryptography-40.0.2=/usr/src/debug/python3-cryptography/40.0.2-r0  -fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build=/usr/src/debug/python3-cryptography/40.0.2-r0  -fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build=/usr/src/debug/python3-cryptography/40.0.2-r0  -fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot=  -fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot=  -fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot-native= ")
|   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
|   CRATE_CC_NO_DEFAULTS = Some("1")
|   Info: default compiler flags are disabled
|   running: "x86_64-poky-linux-gcc" "-m64" "-march=core2" "-mtune=core2" "-msse3" "-mfpmath=sse" "-fstack-protector-strong" "-O2" "-D_FORTIFY_SOURCE=2" "-Wformat" "-Wformat-security" "-Werror=format-security" "--sysroot=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot" "-O2" "-pipe" "-g" "-feliminate-unused-debug-types" "-fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/cryptography-40.0.2=/usr/src/debug/python3-cryptography/40.0.2-r0" "-fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/cryptography-40.0.2=/usr/src/debug/python3-cryptography/40.0.2-r0" "-fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build=/usr/src/debug/python3-cryptography/40.0.2-r0" "-fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build=/usr/src/debug/python3-cryptography/40.0.2-r0" "-fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot=" "-fmacro-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot=" "-fdebug-prefix-map=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot-native=" "-I" "/usr/include/python3.11" "-I" "/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot/usr/include" "-Wconversion" "-Wno-error=sign-conversion" "-Wno-unused-parameter" "-DPy_LIMITED_API=0x030600f0" "-o" "/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build/target/x86_64-poky-linux-gnu/release/build/cryptography-rust-aa00e39a952c07ee/out/9f543b84f9f4dceb-_openssl.o" "-c" "/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build/target/x86_64-poky-linux-gnu/release/build/cryptography-rust-aa00e39a952c07ee/out/_openssl.c"

So the issue is most probably '-I /usr/include/python3.11' among the arguments to the compiler.

| cargo:warning=/srv/build/ttorling/build-upgrades/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/build/target/x86_64-poky-linux-gnu/release/build/cryptography-rust-aa00e39a952c07ee/out/_openssl.c:57:10: fatal error: Python.h: No such file or directory
|   cargo:warning=   57 | #include <Python.h>
|   cargo:warning=      |          ^~~~~~~~~~
|   cargo:warning=compilation terminated.
|   exit status: 1
|
|   --- stderr

which I believe is happening during:
https://github.com/pyca/cryptography/blob/40.0.x/src/rust/build.rs#L74

At https://github.com/pyca/cryptography/blob/f816b457494e010b655cd7fdcd30e3446f86a703/src/rust/build.rs#L46 the path to python includes is defined by calling 'python3 -c "import sysconfig; print(sysconfig.get_path('include'))"' (but from inside rust). With print-debugging this seems to return the bad string '/usr/include/python3.11' which is then passed to cc::Build

I executed this in recipe context:

do_compile:prepend() {
    which python3
    python3 -c "import sysconfig; print(sysconfig.get_path('include'))"
}

and then I got the correct return value:

| /work/yocto/poky/build/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot-native/usr/bin/python3-native/python3 | /work/yocto/poky/build/tmp/work/core2-64-poky-linux/python3-cryptography/40.0.2-r0/recipe-sysroot-native/usr/include/python3.11

On my machine I have python3.10 so the include path is fetched from correct python inside the build. The question is how, why and where the path is stripped?

/Peter


I would appreciate input from any crustaceans out there with a better understanding of what might be happening.

--Tim




-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#180854): 
https://lists.openembedded.org/g/openembedded-core/message/180854
Mute This Topic: https://lists.openembedded.org/mt/98667212/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to