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

Function expand_default_triples

ci-matrix.py:99–172  ·  view source on GitHub ↗

Compute the set of allowed target triples for a pull request. Starts from the explicit defaults in ci-defaults.yaml. When a target dimension has an :all label, that dimension is relaxed and additional triples from ci-targets.yaml that match on the non-expanded dimensions are include

(
    ci_config: dict[str, Any],
    pull_request_defaults: dict[str, Any],
    labels: dict[str, set[str]],
)

Source from the content-addressed store, hash-verified

97
98
99def expand_default_triples(
100 ci_config: dict[str, Any],
101 pull_request_defaults: dict[str, Any],
102 labels: dict[str, set[str]],
103) -> set[str]:
104 """Compute the set of allowed target triples for a pull request.
105
106 Starts from the explicit defaults in ci-defaults.yaml. When a target
107 dimension has an :all label, that dimension is relaxed and additional
108 triples from ci-targets.yaml that match on the non-expanded dimensions
109 are included.
110 """
111 default_triples = set(pull_request_defaults["targets"])
112
113 platform_labels = labels.get("platform", set())
114 arch_labels = labels.get("arch", set())
115 libc_labels = labels.get("libc", set())
116
117 platform_filters = platform_labels - {"all"}
118 arch_filters = arch_labels - {"all"}
119 libc_filters = libc_labels - {"all"}
120
121 expand_platform = "all" in platform_labels or bool(platform_filters)
122 expand_arch = "all" in arch_labels or bool(arch_filters)
123 expand_libc = "all" in libc_labels or bool(libc_filters)
124
125 if not (expand_platform or expand_arch or expand_libc):
126 return default_triples
127
128 # Build reference tuples from the default triples.
129 default_attrs = []
130 for triple in default_triples:
131 platform = find_target_platform(ci_config, triple)
132 config = ci_config[platform][triple]
133 default_attrs.append(
134 (
135 platform,
136 config["arch"],
137 config.get("arch_variant"),
138 config.get("libc"),
139 )
140 )
141
142 # Include any triple whose non-expanded dimensions match a default.
143 allowed = set(default_triples)
144 for platform, platform_config in ci_config.items():
145 for triple, config in platform_config.items():
146 for d_platform, d_arch, d_arch_variant, d_libc in default_attrs:
147 if platform_filters:
148 if platform not in platform_filters:
149 continue
150 elif "all" not in platform_labels and platform != d_platform:
151 continue
152
153 if arch_filters:
154 if config["arch"] not in arch_filters:
155 continue
156 if config.get("arch_variant") != d_arch_variant:

Callers 1

mainFunction · 0.85

Calls 1

find_target_platformFunction · 0.85

Tested by

no test coverage detected