Skip to content

Commit 5b33fe5

Browse files
Backport newer Python setuptools-rust and setuptools
To fix building python3-cryptography with Rust >= 1.83, a newer python3-setuptools-rust is required. As a consequence, newer python3-setuptools is also required to satisfy its dependencies. To simplify maintenance, the versions from scarthgap branch have been used for the backport (1.9.0 and 69.1.1, respectively). Note that extracting the specific cross-compilation fixes from setuptools-rust was considered, but rejected due to the effort required to get all of the required pieces untangled from its commit history, and it not being obvious how to guarantee that the result would not break some downstream usages. Signed-off-by: Scott Murray <[email protected]>
1 parent e1a9005 commit 5b33fe5

8 files changed

+505
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Notes
3838
more potential impact due to upstream API changes and its known to be
3939
finicky build. This may change if sufficient rationale for doing the
4040
backport becomes apparent.
41+
- To support building python3-cryptography with Rust >= 1.83, newer
42+
python3-setuptools-rust and python3-setuptools have been backported
43+
from scarthgap branch. The setuptools backport is higher impact than
44+
desired, but it seems lower risk than accidentally breaking a downstream
45+
use of setuptools-rust trying to patch it to a working state.
4146
- While changes to Rust recipe and class files related to oe-selftest
4247
support are included by necessity, and the Rust selftest is backported
4348
(as "rust_mixin") to simplify the backporting workflow, note that no

conf/layer.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ RUSTVERSION ?= "1.83%"
2020
# and several of them result in parse warnings.
2121
BBMASK:append = " meta/recipes-devtools/cargo/ meta/recipes-devtools/rust/ meta/recipes-gnome/librsvg"
2222

23+
# Mask out old python3-setuptools-rust-native to avoid any conflicts with
24+
# the newer BBCLASSEXTEND version that we carry.
25+
BBMASK:append = " meta/recipes-devtools/python/python3-setuptools-rust-native_%"
26+
2327
# These are in bitbake.conf in langdale and up, adding them here to make
2428
# using the layer more turn-key seems reasonable.
2529
BB_BASEHASH_IGNORE_VARS:append = " RUST_BUILD_SYS RUST_HOST_SYS RUST_TARGET_SYS"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
SUMMARY = "Setuptools Rust extension plugin"
2+
DESCRIPTION = "setuptools-rust is a plugin for setuptools to build Rust \
3+
Python extensions implemented with PyO3 or rust-cpython.\
4+
\
5+
Compile and distribute Python extensions written in Rust as easily as if they were written in C."
6+
HOMEPAGE = "https://github.com/PyO3/setuptools-rust"
7+
BUGTRACKER = "https://github.com/PyO3/setuptools-rust/issues"
8+
9+
LICENSE = "MIT"
10+
LIC_FILES_CHKSUM = "file://LICENSE;md5=011cd92e702dd9e6b1a26157b6fd53f5"
11+
12+
SRC_URI = "${PYPI_SRC_URI} \
13+
https://files.pythonhosted.org/packages/67/08/e1aa2c582c62ac76e4d60f8e454bd3bba933781a06a88b4e38797445822a/setuptools-rust-${PV}.tar.gz \
14+
"
15+
SRC_URI[sha256sum] = "704df0948f2e4cc60c2596ad6e840ea679f4f43e58ed4ad0c1857807240eab96"
16+
17+
inherit cargo pypi python_setuptools_build_meta
18+
19+
DEPENDS += "python3-setuptools-scm-native python3-wheel-native"
20+
# remove when https://github.com/PyO3/setuptools-rust/commit/7ced8d2a8f36e1b4fc41b5544636defb7bd44bdf
21+
# is included
22+
DEPENDS += "python3-semantic-version-native"
23+
24+
RDEPENDS:${PN} += " \
25+
python3-json \
26+
python3-semantic-version \
27+
python3-setuptools \
28+
python3-setuptools-scm \
29+
python3-shell \
30+
python3-toml \
31+
python3-typing-extensions \
32+
python3-wheel \
33+
"
34+
35+
BBCLASSEXTEND = "native nativesdk"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This seems required to reliably build python3-setuptools-scm-native
2+
DEPENDS += "python3-tomli-native"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
From d393759315b189a738e4b6a2ce31dc18dbbfae29 Mon Sep 17 00:00:00 2001
2+
From: Alexander Kanavin <[email protected]>
3+
Date: Wed, 11 May 2022 21:41:14 +0200
4+
Subject: [PATCH] _distutils/sysconfig.py: make it possible to substite the
5+
prefix to target sysroot
6+
7+
This is done by probing STAGING_INCDIR/STAGING_LIBDIRenv vars:
8+
not the most elegant solution, but distutils/sysconfig has been
9+
tweaked to do this for many, many year, and so it's easiest
10+
to replicate here as well, the original is
11+
meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch
12+
13+
I'm not sure exactly why setuptools now needs a copy, and what
14+
would happen to this module in light of distutils deprecation.
15+
16+
Upstream-Status: Inappropriate [oe-core specific]
17+
Signed-off-by: Alexander Kanavin <[email protected]>
18+
---
19+
setuptools/_distutils/sysconfig.py | 12 ++++++++++--
20+
1 file changed, 10 insertions(+), 2 deletions(-)
21+
22+
diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py
23+
index a40a723..14f35e7 100644
24+
--- a/setuptools/_distutils/sysconfig.py
25+
+++ b/setuptools/_distutils/sysconfig.py
26+
@@ -119,6 +119,8 @@ def get_python_inc(plat_specific=0, prefix=None):
27+
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
28+
"""
29+
default_prefix = BASE_EXEC_PREFIX if plat_specific else BASE_PREFIX
30+
+ if os.environ.get('STAGING_INCDIR', ""):
31+
+ default_prefix = os.environ['STAGING_INCDIR'].rstrip('include')
32+
resolved_prefix = prefix if prefix is not None else default_prefix
33+
try:
34+
getter = globals()[f'_get_python_inc_{os.name}']
35+
@@ -238,7 +240,13 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
36+
37+
early_prefix = prefix
38+
39+
- if prefix is None:
40+
+ if os.environ.get('STAGING_LIBDIR', ""):
41+
+ lib_basename = os.environ['STAGING_LIBDIR'].split('/')[-1]
42+
+ else:
43+
+ lib_basename = "lib"
44+
+ if prefix is None and os.environ.get('STAGING_LIBDIR', ""):
45+
+ prefix = os.environ['STAGING_LIBDIR'].rstrip(lib_basename)
46+
+ elif prefix is None:
47+
if standard_lib:
48+
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
49+
else:
50+
@@ -253,7 +261,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
51+
# Pure Python
52+
libdir = "lib"
53+
implementation = 'pypy' if IS_PYPY else 'python'
54+
- libpython = os.path.join(prefix, libdir, implementation + get_python_version())
55+
+ libpython = os.path.join(prefix, lib_basename, implementation + get_python_version())
56+
return _posix_lib(standard_lib, libpython, early_prefix, prefix)
57+
elif os.name == "nt":
58+
if standard_lib:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 40648dfa770f9f7b9b9efa501c9ef7af96be9f2d Mon Sep 17 00:00:00 2001
2+
From: Hongxu Jia <[email protected]>
3+
Date: Tue, 17 Jul 2018 10:13:38 +0800
4+
Subject: [PATCH] conditionally do not fetch code by easy_install
5+
6+
If var-NO_FETCH_BUILD is set, do not allow to fetch code from
7+
internet by easy_install.
8+
9+
Upstream-Status: Inappropriate [oe specific]
10+
11+
Signed-off-by: Hongxu Jia <[email protected]>
12+
---
13+
setuptools/command/easy_install.py | 5 +++++
14+
1 file changed, 5 insertions(+)
15+
16+
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
17+
index 5d6fd5c..377e575 100644
18+
--- a/setuptools/command/easy_install.py
19+
+++ b/setuptools/command/easy_install.py
20+
@@ -676,6 +676,11 @@ class easy_install(Command):
21+
os.path.exists(tmpdir) and _rmtree(tmpdir)
22+
23+
def easy_install(self, spec, deps=False):
24+
+ if os.environ.get('NO_FETCH_BUILD', None):
25+
+ log.error("ERROR: Do not try to fetch `%s' for building. "
26+
+ "Please add its native recipe to DEPENDS." % spec)
27+
+ return None
28+
+
29+
with self._tmpdir() as tmpdir:
30+
if not isinstance(spec, Requirement):
31+
if URL_SCHEME(spec):

0 commit comments

Comments
 (0)