summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/python/python3-cython/0001-WIP-prefix-map.patch148
-rw-r--r--meta/recipes-devtools/python/python3-cython_3.0.11.bb1
2 files changed, 149 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-cython/0001-WIP-prefix-map.patch b/meta/recipes-devtools/python/python3-cython/0001-WIP-prefix-map.patch
new file mode 100644
index 0000000000..adc9463ffa
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-cython/0001-WIP-prefix-map.patch
@@ -0,0 +1,148 @@
1From 4d1b7911372561b22e03c7f2b4ec807502b5b9c1 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@arm.com>
3Date: Mon, 4 Nov 2024 15:36:39 +0000
4Subject: [PATCH] WIP prefix map
5
6Upstream-Status: Inappropriate
7Signed-off-by: Ross Burton <ross.burton@arm.com>
8---
9 Cython/Compiler/CmdLine.py | 9 ++++++++-
10 Cython/Compiler/Main.py | 9 +++++----
11 Cython/Compiler/Options.py | 1 +
12 Cython/Compiler/Parsing.py | 1 +
13 Cython/Compiler/Scanning.py | 9 +++++++--
14 5 files changed, 22 insertions(+), 7 deletions(-)
15
16diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py
17index 776636c..f5a7c79 100644
18--- a/Cython/Compiler/CmdLine.py
19+++ b/Cython/Compiler/CmdLine.py
20@@ -74,6 +74,12 @@ class SetAnnotateCoverageAction(Action):
21 namespace.annotate = True
22 namespace.annotate_coverage_xml = values
23
24+class SetPrefixMapAction(Action):
25+ def __call__(self, parser, namespace, values, option_string=None):
26+ mappings = getattr(namespace, self.dest, {})
27+ k, v = values.split("=", 1)
28+ mappings[k] = v
29+ setattr(namespace, self.dest, mappings)
30
31 def create_cython_argparser():
32 description = "Cython (https://cython.org/) is a compiler for code written in the "\
33@@ -157,9 +163,10 @@ def create_cython_argparser():
34 'deduced from the import path if source file is in '
35 'a package, or equals the filename otherwise.')
36 parser.add_argument('-M', '--depfile', action='store_true', help='produce depfiles for the sources')
37+ # TODO: add help
38+ parser.add_argument("--prefix-map", action=SetPrefixMapAction)
39 parser.add_argument('sources', nargs='*', default=[])
40
41- # TODO: add help
42 parser.add_argument("-z", "--pre-import", dest='pre_import', action='store', type=str, help=SUPPRESS)
43 parser.add_argument("--convert-range", dest='convert_range', action='store_true', help=SUPPRESS)
44 parser.add_argument("--no-c-in-traceback", dest='c_line_in_traceback', action='store_false', help=SUPPRESS)
45diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
46index 80946c0..28cfe68 100644
47--- a/Cython/Compiler/Main.py
48+++ b/Cython/Compiler/Main.py
49@@ -70,7 +70,7 @@ class Context(object):
50 language_level = None # warn when not set but default to Py2
51
52 def __init__(self, include_directories, compiler_directives, cpp=False,
53- language_level=None, options=None):
54+ language_level=None, prefix_map=None, options=None):
55 # cython_scope is a hack, set to False by subclasses, in order to break
56 # an infinite loop.
57 # Better code organization would fix it.
58@@ -83,6 +83,7 @@ class Context(object):
59 self.future_directives = set()
60 self.compiler_directives = compiler_directives
61 self.cpp = cpp
62+ self.prefix_map = prefix_map or {}
63 self.options = options
64
65 self.pxds = {} # full name -> node tree
66@@ -98,7 +99,7 @@ class Context(object):
67 @classmethod
68 def from_options(cls, options):
69 return cls(options.include_path, options.compiler_directives,
70- options.cplus, options.language_level, options=options)
71+ options.cplus, options.language_level, prefix_map=options.prefix_map, options=options)
72
73 def set_language_level(self, level):
74 from .Future import print_function, unicode_literals, absolute_import, division, generator_stop
75@@ -259,7 +260,7 @@ class Context(object):
76 rel_path = module_name.replace('.', os.sep) + os.path.splitext(pxd_pathname)[1]
77 if not pxd_pathname.endswith(rel_path):
78 rel_path = pxd_pathname # safety measure to prevent printing incorrect paths
79- source_desc = FileSourceDescriptor(pxd_pathname, rel_path)
80+ source_desc = FileSourceDescriptor(pxd_pathname, rel_path, prefix_map=self.prefix_map)
81 err, result = self.process_pxd(source_desc, scope, qualified_name)
82 if err:
83 raise err
84@@ -509,7 +510,7 @@ def run_pipeline(source, options, full_module_name=None, context=None):
85 rel_path = source # safety measure to prevent printing incorrect paths
86 else:
87 rel_path = abs_path
88- source_desc = FileSourceDescriptor(abs_path, rel_path)
89+ source_desc = FileSourceDescriptor(abs_path, rel_path, prefix_map=context.prefix_map)
90 source = CompilationSource(source_desc, full_module_name, cwd)
91
92 # Set up result object
93diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py
94index 61950a7..cc52732 100644
95--- a/Cython/Compiler/Options.py
96+++ b/Cython/Compiler/Options.py
97@@ -796,4 +796,5 @@ default_options = dict(
98 create_extension=None,
99 np_pythran=False,
100 legacy_implicit_noexcept=None,
101+ prefix_map=dict(pair.split("=", 1) for pair in os.environ.get("CYTHON_PREFIX_MAP", "").split()),
102 )
103diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
104index 25c0de9..6c0eccf 100644
105--- a/Cython/Compiler/Parsing.py
106+++ b/Cython/Compiler/Parsing.py
107@@ -2106,6 +2106,7 @@ def p_include_statement(s, ctx):
108 s.included_files.append(include_file_name)
109 with Utils.open_source_file(include_file_path) as f:
110 source_desc = FileSourceDescriptor(include_file_path)
111+ print(f"TODO Cannot use prefix map on {include_file_path}")
112 s2 = PyrexScanner(f, source_desc, s, source_encoding=f.encoding, parse_comments=s.parse_comments)
113 tree = p_statement_list(s2, ctx)
114 return tree
115diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py
116index 372392b..0fa3b30 100644
117--- a/Cython/Compiler/Scanning.py
118+++ b/Cython/Compiler/Scanning.py
119@@ -195,7 +195,7 @@ class FileSourceDescriptor(SourceDescriptor):
120 optional name argument and will be passed back when asking for
121 the position()-tuple.
122 """
123- def __init__(self, filename, path_description=None):
124+ def __init__(self, filename, path_description=None, prefix_map={}):
125 filename = Utils.decode_filename(filename)
126 self.path_description = path_description or filename
127 self.filename = filename
128@@ -205,6 +205,7 @@ class FileSourceDescriptor(SourceDescriptor):
129 self.set_file_type_from_name(filename)
130 self._cmp_name = filename
131 self._lines = {}
132+ self.prefix_map = prefix_map
133
134 def get_lines(self, encoding=None, error_handling=None):
135 # we cache the lines only the second time this is called, in
136@@ -243,7 +244,11 @@ class FileSourceDescriptor(SourceDescriptor):
137 return path
138
139 def get_filenametable_entry(self):
140- return self.file_path
141+ entry = self.file_path
142+ for k, v in self.prefix_map.items():
143+ # TODO: should just replace the prefix
144+ entry = entry.replace(k, v)
145+ return entry
146
147 def __eq__(self, other):
148 return isinstance(other, FileSourceDescriptor) and self.filename == other.filename
diff --git a/meta/recipes-devtools/python/python3-cython_3.0.11.bb b/meta/recipes-devtools/python/python3-cython_3.0.11.bb
index 980cb04636..efce67d092 100644
--- a/meta/recipes-devtools/python/python3-cython_3.0.11.bb
+++ b/meta/recipes-devtools/python/python3-cython_3.0.11.bb
@@ -7,6 +7,7 @@ SECTION = "devel/python"
7LICENSE = "Apache-2.0" 7LICENSE = "Apache-2.0"
8LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=61c3ee8961575861fa86c7e62bc9f69c" 8LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=61c3ee8961575861fa86c7e62bc9f69c"
9 9
10SRC_URI += "file://0001-WIP-prefix-map.patch"
10SRC_URI[sha256sum] = "7146dd2af8682b4ca61331851e6aebce9fe5158e75300343f80c07ca80b1faff" 11SRC_URI[sha256sum] = "7146dd2af8682b4ca61331851e6aebce9fe5158e75300343f80c07ca80b1faff"
11 12
12inherit pypi setuptools3 13inherit pypi setuptools3