MCPcopy Create free account
hub / github.com/astral-sh/python-build-standalone / should_include_entry

Function should_include_entry

ci-matrix.py:175–232  ·  view source on GitHub ↗

Check if a matrix entry should be included. For pull requests, entries are restricted to the allowed target set (computed by expand_default_triples), the default python version, and the curated build options — unless overridden by labels. For pushes (pull_request_defaults is None),

(
    entry: dict[str, str],
    labels: dict[str, set[str]],
    pull_request_defaults: dict[str, Any] | None = None,
    allowed_triples: set[str] | None = None,
)

Source from the content-addressed store, hash-verified

173
174
175def should_include_entry(
176 entry: dict[str, str],
177 labels: dict[str, set[str]],
178 pull_request_defaults: dict[str, Any] | None = None,
179 allowed_triples: set[str] | None = None,
180) -> bool:
181 """Check if a matrix entry should be included.
182
183 For pull requests, entries are restricted to the allowed target set
184 (computed by expand_default_triples), the default python version, and
185 the curated build options — unless overridden by labels. For pushes
186 (pull_request_defaults is None), only label filters apply.
187 """
188 if pull_request_defaults is not None:
189 triple = entry["target_triple"]
190 default_targets = pull_request_defaults["targets"]
191
192 # Target must be in the allowed set.
193 if allowed_triples is not None and triple not in allowed_triples:
194 return False
195
196 # Python: restrict to default version unless python labels override.
197 if not labels.get("python"):
198 if entry["python"] != pull_request_defaults["python_version"]:
199 return False
200
201 # Build options: restrict to curated defaults for default triples
202 # unless build labels override. Non-default triples (brought in by
203 # :all expansion) are unrestricted.
204 if not labels.get("build") and triple in default_targets:
205 if entry["build_options"] not in default_targets[triple]["build_options"]:
206 return False
207
208 # Label filters
209 platform_filters = labels.get("platform", set()) - {"all"}
210 if platform_filters and entry["platform"] not in platform_filters:
211 return False
212
213 python_filters = labels.get("python", set()) - {"all"}
214 if python_filters and entry["python"] not in python_filters:
215 return False
216
217 arch_filters = labels.get("arch", set()) - {"all"}
218 if arch_filters and entry["arch"] not in arch_filters:
219 return False
220
221 libc_filters = labels.get("libc", set()) - {"all"}
222 if libc_filters and entry.get("libc") and entry["libc"] not in libc_filters:
223 return False
224
225 build_filters = labels.get("build", set()) - {"all"}
226 if build_filters:
227 build_components = set(entry.get("build_options", "").split("+"))
228 required = {c for f in build_filters for c in f.split("+")}
229 if not required.issubset(build_components):
230 return False
231
232 return True

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected