new file mode 100644
@@ -0,0 +1,94 @@
+From f3cfdebd75374a29a930687c1f126282c51b7a92 Mon Sep 17 00:00:00 2001
+From: mv-python <matusvalo@users.noreply.github.com>
+Date: Fri, 12 Jun 2026 10:32:42 +0200
+Subject: [PATCH] [3.2.x] Shared module: Use `SharedUtilitySourceDescriptor`
+ instead of temporary directory (#7723) (GH-7739)
+
+This PR uses `SharedUtilitySourceDescriptor` instead of an empty pyx
+file in the temp dir. This simplifies the logic and also assures that
+`__pyx_f` is unchanged across builds.
+
+Backport of https://github.com/cython/cython/pull/7723
+Alternative to https://github.com/cython/cython/pull/7634
+
+Upstream-Status: Backport [https://github.com/cython/cython/commit/f3cfdebd75374a29a930687c1f126282c51b7a92]
+
+Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
+---
+ Cython/Build/SharedModule.py | 25 ++++++++-----------------
+ Cython/Compiler/Scanning.py | 9 +++++++++
+ 2 files changed, 17 insertions(+), 17 deletions(-)
+
+diff --git a/Cython/Build/SharedModule.py b/Cython/Build/SharedModule.py
+index fed6263cd..45da4b462 100644
+--- a/Cython/Build/SharedModule.py
++++ b/Cython/Build/SharedModule.py
+@@ -1,13 +1,10 @@
+ import os
+-import re
+-import shutil
+-import tempfile
+
+ from Cython.Compiler import (
+ MemoryView, Code, Options, Pipeline, Errors, Main, Symtab
+ )
+ from Cython.Compiler.StringEncoding import EncodedString
+-from Cython.Compiler.Scanning import FileSourceDescriptor
++from Cython.Compiler.Scanning import SharedUtilitySourceDescriptor
+
+
+ def create_shared_library_pipeline(context, scope, options, result):
+@@ -72,23 +69,17 @@ def generate_shared_module(options):
+ Errors.open_listing_file(None)
+
+ dest_c_file = options.shared_c_file_path
++ pyx_file = os.path.splitext(dest_c_file)[0] + '.pyx'
+ module_name = os.path.splitext(os.path.basename(dest_c_file))[0]
+
+ context = Main.Context.from_options(options)
+ scope = Symtab.ModuleScope('MemoryView', parent_module = None, context = context, is_package=False)
+
+- with tempfile.TemporaryDirectory() as tmpdirname:
+- pyx_file = os.path.join(tmpdirname, f'{module_name}.pyx')
+- c_file = os.path.join(tmpdirname, f'{module_name}.c')
+- with open(pyx_file, 'w'):
+- pass
+- source_desc = FileSourceDescriptor(pyx_file)
+- comp_src = Main.CompilationSource(source_desc, EncodedString(module_name), os.getcwd())
+- result = Main.create_default_resultobj(comp_src, options)
+-
+- pipeline = create_shared_library_pipeline(context, scope, options, result)
+- err, enddata = Pipeline.run_pipeline(pipeline, comp_src)
+- if err is None:
+- shutil.copy(c_file, dest_c_file)
++ source_desc = SharedUtilitySourceDescriptor(pyx_file)
++ comp_src = Main.CompilationSource(source_desc, EncodedString(module_name), os.getcwd())
++ result = Main.create_default_resultobj(comp_src, options)
++
++ pipeline = create_shared_library_pipeline(context, scope, options, result)
++ err, enddata = Pipeline.run_pipeline(pipeline, comp_src)
+
+ return err, enddata
+diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py
+index 2a8cb5a93..4cec7d1ed 100644
+--- a/Cython/Compiler/Scanning.py
++++ b/Cython/Compiler/Scanning.py
+@@ -281,6 +281,15 @@ class StringSourceDescriptor(SourceDescriptor):
+ return "<StringSourceDescriptor:%s>" % self.name
+
+
++class SharedUtilitySourceDescriptor(FileSourceDescriptor):
++ """
++ A specialized source descriptor for shared utility code only. Not part of public API.
++ """
++
++ def get_file_object(self, encoding=None, error_handling=None):
++ from io import StringIO
++ return StringIO('')
++
+ #------------------------------------------------------------------
+
+ class PyrexScanner(Scanner):
+--
+2.43.0
+
@@ -13,6 +13,7 @@ inherit pypi setuptools3 cython
SRC_URI += " \
file://0001-Replace-not-predictable-build-path-prefix-with-hardc.patch \
+ file://0001-3.2.x-Shared-module-Use-SharedUtilitySourceDescripto.patch \
"
# No need to depend on self
While python3 module use cython to build shared moudle utility library, the generated source file _cyutility.c is not stable at each build and made the generated library not be reproducible. When the option "--generated-shared" is used to generated __cyutility as the link https://github.com/scikit-learn/scikit-learn/pull/31151/files, the path for filename_table in the generated pyx/c file contains tmp dir which is not predictable though it has been updated to the relative path, and it caused the generated output file is not stable at each build and made the generated library is not reproducible [1] between builds. example as python3_pandas: vim build/_cyutility.c ...... /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "../../../../../../../../../../../../tmp/tmpXXXXXX/_cyutility.pyx", "<stringsource>", }; After applied this commit, vim build/_cyutility.c ...... /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "_cyutility.pyx", "<stringsource>", }; This commit use SharedUtilitySourceDescriptor instead of unpredictable temporary directory unpredictable tmpdir in the generated source file to assure the file _cyutility.c should be reproducible. [1] https://reproducible-builds.org/ Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> --- ...ule-Use-SharedUtilitySourceDescripto.patch | 94 +++++++++++++++++++ .../python/python3-cython_3.2.5.bb | 1 + 2 files changed, 95 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-cython/0001-3.2.x-Shared-module-Use-SharedUtilitySourceDescripto.patch