summaryrefslogtreecommitdiffstats
path: root/meta-python
diff options
context:
space:
mode:
authorYoann Congal <yoann.congal@smile.fr>2025-04-13 10:08:02 +0200
committerKhem Raj <raj.khem@gmail.com>2025-04-15 12:52:18 -0700
commit5db973d20ab4abe0ae9a7265e6b1f97d58f0741b (patch)
treea78aa20c11278d83076aa7d049a6eab811dd7bb4 /meta-python
parent20ac5b207d0ead00db21e70fafa4449e2aad490f (diff)
downloadmeta-openembedded-5db973d20ab4abe0ae9a7265e6b1f97d58f0741b.tar.gz
python3-evdev: Fix buildpaths errors and reproducibility
Add a submitted patch to support the reproducible generation of intermediate file ecodes.c, then, use it to fix the buildpaths errors. Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-python')
-rw-r--r--meta-python/recipes-devtools/python/python3-evdev/0001-Add-a-reproducibility-option-for-building-ecodes.c.patch116
-rw-r--r--meta-python/recipes-devtools/python/python3-evdev_1.9.1.bb5
2 files changed, 119 insertions, 2 deletions
diff --git a/meta-python/recipes-devtools/python/python3-evdev/0001-Add-a-reproducibility-option-for-building-ecodes.c.patch b/meta-python/recipes-devtools/python/python3-evdev/0001-Add-a-reproducibility-option-for-building-ecodes.c.patch
new file mode 100644
index 0000000000..e730519884
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-evdev/0001-Add-a-reproducibility-option-for-building-ecodes.c.patch
@@ -0,0 +1,116 @@
1From d05c1c9dd298cb95d7feccbddb5caa043a319a01 Mon Sep 17 00:00:00 2001
2From: Yoann Congal <yoann.congal@smile.fr>
3Date: Sun, 13 Apr 2025 00:52:13 +0200
4Subject: [PATCH] Add a reproducibility option for building ecodes.c
5
6ecodes.c currently contains the kernel info of the build machine and the
7full path of the input*.h headers: This is not reproducible as output
8can change even is headers content do not. Downstream distributions
9might package ecodes.c and get non-reproducible output.
10
11To fix this: introduce a --reproducible option in the build:
12- in setup.py build_ecodes command
13- in underlying genecodes_c.py
14
15Note: These options are disabled by default so no change is expected in
16current builds.
17
18Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
19Upstream-Status: Submitted [https://github.com/gvalkov/python-evdev/pull/242]
20---
21 setup.py | 13 ++++++++++---
22 src/evdev/genecodes_c.py | 17 +++++++++++------
23 2 files changed, 21 insertions(+), 9 deletions(-)
24
25diff --git a/setup.py b/setup.py
26index 6b721d7..3371199 100755
27--- a/setup.py
28+++ b/setup.py
29@@ -14,7 +14,7 @@ curdir = Path(__file__).resolve().parent
30 ecodes_c_path = curdir / "src/evdev/ecodes.c"
31
32
33-def create_ecodes(headers=None):
34+def create_ecodes(headers=None, reproducibility=False):
35 if not headers:
36 include_paths = set()
37 cpath = os.environ.get("CPATH", "").strip()
38@@ -65,7 +65,10 @@ def create_ecodes(headers=None):
39
40 print("writing %s (using %s)" % (ecodes_c_path, " ".join(headers)))
41 with ecodes_c_path.open("w") as fh:
42- cmd = [sys.executable, "src/evdev/genecodes_c.py", "--ecodes", *headers]
43+ cmd = [sys.executable, "src/evdev/genecodes_c.py"]
44+ if reproducibility:
45+ cmd.append("--reproducibility")
46+ cmd.extend(["--ecodes", *headers])
47 run(cmd, check=True, stdout=fh)
48
49
50@@ -74,17 +77,21 @@ class build_ecodes(Command):
51
52 user_options = [
53 ("evdev-headers=", None, "colon-separated paths to input subsystem headers"),
54+ ("reproducibility", None, "hide host details (host/paths) to create a reproducible output"),
55 ]
56
57 def initialize_options(self):
58 self.evdev_headers = None
59+ self.reproducibility = False
60
61 def finalize_options(self):
62 if self.evdev_headers:
63 self.evdev_headers = self.evdev_headers.split(":")
64+ if self.reproducibility is None:
65+ self.reproducibility = False
66
67 def run(self):
68- create_ecodes(self.evdev_headers)
69+ create_ecodes(self.evdev_headers, reproducibility=self.reproducibility)
70
71
72 class build_ext(_build_ext.build_ext):
73diff --git a/src/evdev/genecodes_c.py b/src/evdev/genecodes_c.py
74index 5c2d946..24cad27 100644
75--- a/src/evdev/genecodes_c.py
76+++ b/src/evdev/genecodes_c.py
77@@ -15,22 +15,27 @@ headers = [
78 "/usr/include/linux/uinput.h",
79 ]
80
81-opts, args = getopt.getopt(sys.argv[1:], "", ["ecodes", "stubs"])
82+opts, args = getopt.getopt(sys.argv[1:], "", ["ecodes", "stubs", "reproducibility"])
83 if not opts:
84- print("usage: genecodes.py [--ecodes|--stubs] <headers>")
85+ print("usage: genecodes.py [--ecodes|--stubs] [--reproducibility] <headers>")
86 exit(2)
87
88 if args:
89 headers = args
90
91+reproducibility = ("--reproducibility", "") in opts
92+
93
94 # -----------------------------------------------------------------------------
95 macro_regex = r"#define\s+((?:KEY|ABS|REL|SW|MSC|LED|BTN|REP|SND|ID|EV|BUS|SYN|FF|UI_FF|INPUT_PROP)_\w+)"
96 macro_regex = re.compile(macro_regex)
97
98-# Uname without hostname.
99-uname = list(os.uname())
100-uname = " ".join((uname[0], *uname[2:]))
101+if reproducibility:
102+ uname = "hidden for reproducibility"
103+else:
104+ # Uname without hostname.
105+ uname = list(os.uname())
106+ uname = " ".join((uname[0], *uname[2:]))
107
108
109 # -----------------------------------------------------------------------------
110@@ -138,5 +143,5 @@ elif ("--stubs", "") in opts:
111 template = template_stubs
112
113 body = os.linesep.join(body)
114-text = template % (uname, headers, body)
115+text = template % (uname, headers if not reproducibility else ["hidden for reproducibility"], body)
116 print(text.strip())
diff --git a/meta-python/recipes-devtools/python/python3-evdev_1.9.1.bb b/meta-python/recipes-devtools/python/python3-evdev_1.9.1.bb
index b8930c97d5..af88770c59 100644
--- a/meta-python/recipes-devtools/python/python3-evdev_1.9.1.bb
+++ b/meta-python/recipes-devtools/python/python3-evdev_1.9.1.bb
@@ -3,6 +3,7 @@ HOMEPAGE = "https://github.com/gvalkov/python-evdev"
3LICENSE = "BSD-3-Clause" 3LICENSE = "BSD-3-Clause"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=d7bd1cc4c71b706c7e2d4053aef50f2a" 4LIC_FILES_CHKSUM = "file://LICENSE;md5=d7bd1cc4c71b706c7e2d4053aef50f2a"
5 5
6SRC_URI += "file://0001-Add-a-reproducibility-option-for-building-ecodes.c.patch"
6SRC_URI[sha256sum] = "dc640a064cb1c9fe1f8b970dc2039945a2a275d7b7ee62284bf427238abe45ee" 7SRC_URI[sha256sum] = "dc640a064cb1c9fe1f8b970dc2039945a2a275d7b7ee62284bf427238abe45ee"
7 8
8inherit pypi python_setuptools_build_meta 9inherit pypi python_setuptools_build_meta
@@ -12,7 +13,8 @@ do_compile:prepend() {
12} 13}
13 14
14PEP517_BUILD_OPTS = "--config-setting=--build-option='build_ecodes \ 15PEP517_BUILD_OPTS = "--config-setting=--build-option='build_ecodes \
15 --evdev-headers ${STAGING_DIR_TARGET}/usr/include/linux/input.h:${STAGING_DIR_TARGET}/usr/include/linux/input-event-codes.h'" 16 --evdev-headers ${STAGING_DIR_TARGET}/usr/include/linux/input.h:${STAGING_DIR_TARGET}/usr/include/linux/input-event-codes.h \
17 --reproducibility'"
16 18
17RDEPENDS:${PN} += "\ 19RDEPENDS:${PN} += "\
18 python3-ctypes \ 20 python3-ctypes \
@@ -21,4 +23,3 @@ RDEPENDS:${PN} += "\
21 python3-shell \ 23 python3-shell \
22 python3-stringold \ 24 python3-stringold \
23 " 25 "
24INSANE_SKIP:${PN}-src = "buildpaths"