MCPcopy Index your code
hub / github.com/astral-sh/python-build-standalone / write_triples_makefiles

Function write_triples_makefiles

pythonbuild/utils.py:176–219  ·  view source on GitHub ↗

Write out makefiles containing make variable settings derived from config.

(
    targets, dest_dir: pathlib.Path, support_search_dir: pathlib.Path
)

Source from the content-addressed store, hash-verified

174
175
176def write_triples_makefiles(
177 targets, dest_dir: pathlib.Path, support_search_dir: pathlib.Path
178):
179 """Write out makefiles containing make variable settings derived from config."""
180 dest_dir.mkdir(parents=True, exist_ok=True)
181
182 for triple, settings in targets.items():
183 for host_platform in settings["host_platforms"]:
184 # IMPORTANT: if we ever vary the content of these Makefiles by
185 # Python versions, the variable names will need add the Python
186 # version and the Makefile references updated to point to specific
187 # versions. If we don't do that, multi-version builds will fail
188 # to work correctly.
189
190 makefile_path = dest_dir / ("Makefile.%s.%s" % (host_platform, triple))
191
192 lines = []
193 for need in settings.get("needs", []):
194 lines.append(
195 "NEED_%s := 1\n" % need.upper().replace("-", "_").replace(".", "_")
196 )
197
198 image_suffix = settings.get("docker_image_suffix", "")
199
200 # On cross builds, we can just use the bare `gcc` image
201 gcc_image_suffix = (
202 image_suffix if not image_suffix.startswith(".cross") else ""
203 )
204
205 lines.append("DOCKER_IMAGE_BUILD := build%s\n" % image_suffix)
206 lines.append("DOCKER_IMAGE_GCC := gcc%s\n" % gcc_image_suffix)
207
208 entry = clang_toolchain(host_platform, triple)
209 lines.append(
210 "CLANG_FILENAME := %s-%s-%s.tar\n"
211 % (entry, DOWNLOADS[entry]["version"], host_platform)
212 )
213
214 lines.append(
215 "PYTHON_SUPPORT_FILES := $(PYTHON_SUPPORT_FILES) %s\n"
216 % (support_search_dir / "extension-modules.yml")
217 )
218
219 write_if_different(makefile_path, "".join(lines).encode("ascii"))
220
221
222def write_package_versions(dest_path: pathlib.Path):

Callers 1

mainFunction · 0.90

Calls 2

clang_toolchainFunction · 0.85
write_if_differentFunction · 0.85

Tested by

no test coverage detected