summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-cryptography/0001-Fix-include-directory-when-cross-compiling-9129.patch
blob: d720359ded70eb7cb20b5badd7396032a8736642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 2f9cd402d3293f6efe0f3ac06f17c6c14edbed86 Mon Sep 17 00:00:00 2001
From: James Hilliard <james.hilliard1@gmail.com>
Date: Sun, 25 Jun 2023 17:39:19 -0600
Subject: [PATCH] Fix include directory when cross compiling (#9129)

Upstream-Status: Backport [https://github.com/pyca/cryptography/pull/9129]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 src/rust/cryptography-cffi/build.rs | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/rust/cryptography-cffi/build.rs b/src/rust/cryptography-cffi/build.rs
index 07590ad2e..384af1ddb 100644
--- a/src/rust/cryptography-cffi/build.rs
+++ b/src/rust/cryptography-cffi/build.rs
@@ -47,9 +47,14 @@ fn main() {
     )
     .unwrap();
     println!("cargo:rustc-cfg=python_implementation=\"{}\"", python_impl);
-    let python_include = run_python_script(
+    let python_includes = run_python_script(
         &python,
-        "import sysconfig; print(sysconfig.get_path('include'), end='')",
+        "import os; \
+         import setuptools.dist; \
+         import setuptools.command.build_ext; \
+         b = setuptools.command.build_ext.build_ext(setuptools.dist.Distribution()); \
+         b.finalize_options(); \
+         print(os.pathsep.join(b.include_dirs), end='')",
     )
     .unwrap();
     let openssl_include =
@@ -59,12 +64,15 @@ fn main() {
     let mut build = cc::Build::new();
     build
         .file(openssl_c)
-        .include(python_include)
         .include(openssl_include)
         .flag_if_supported("-Wconversion")
         .flag_if_supported("-Wno-error=sign-conversion")
         .flag_if_supported("-Wno-unused-parameter");
 
+    for python_include in env::split_paths(&python_includes) {
+        build.include(python_include);
+    }
+
     // Enable abi3 mode if we're not using PyPy.
     if python_impl != "PyPy" {
         // cp37 (Python 3.7 to help our grep when we some day drop 3.7 support)
-- 
2.30.2