blob: d720359ded70eb7cb20b5badd7396032a8736642 [file] [log] [blame]
Andrew Geissler8f840682023-07-21 09:09:43 -05001From 2f9cd402d3293f6efe0f3ac06f17c6c14edbed86 Mon Sep 17 00:00:00 2001
2From: James Hilliard <james.hilliard1@gmail.com>
3Date: Sun, 25 Jun 2023 17:39:19 -0600
4Subject: [PATCH] Fix include directory when cross compiling (#9129)
5
6Upstream-Status: Backport [https://github.com/pyca/cryptography/pull/9129]
7Signed-off-by: Alexander Kanavin <alex@linutronix.de>
8---
9 src/rust/cryptography-cffi/build.rs | 14 +++++++++++---
10 1 file changed, 11 insertions(+), 3 deletions(-)
11
12diff --git a/src/rust/cryptography-cffi/build.rs b/src/rust/cryptography-cffi/build.rs
13index 07590ad2e..384af1ddb 100644
14--- a/src/rust/cryptography-cffi/build.rs
15+++ b/src/rust/cryptography-cffi/build.rs
16@@ -47,9 +47,14 @@ fn main() {
17 )
18 .unwrap();
19 println!("cargo:rustc-cfg=python_implementation=\"{}\"", python_impl);
20- let python_include = run_python_script(
21+ let python_includes = run_python_script(
22 &python,
23- "import sysconfig; print(sysconfig.get_path('include'), end='')",
24+ "import os; \
25+ import setuptools.dist; \
26+ import setuptools.command.build_ext; \
27+ b = setuptools.command.build_ext.build_ext(setuptools.dist.Distribution()); \
28+ b.finalize_options(); \
29+ print(os.pathsep.join(b.include_dirs), end='')",
30 )
31 .unwrap();
32 let openssl_include =
33@@ -59,12 +64,15 @@ fn main() {
34 let mut build = cc::Build::new();
35 build
36 .file(openssl_c)
37- .include(python_include)
38 .include(openssl_include)
39 .flag_if_supported("-Wconversion")
40 .flag_if_supported("-Wno-error=sign-conversion")
41 .flag_if_supported("-Wno-unused-parameter");
42
43+ for python_include in env::split_paths(&python_includes) {
44+ build.include(python_include);
45+ }
46+
47 // Enable abi3 mode if we're not using PyPy.
48 if python_impl != "PyPy" {
49 // cp37 (Python 3.7 to help our grep when we some day drop 3.7 support)
50--
512.30.2
52