Skip to content

Commit

Permalink
fix up references to clang in linux x86_64 pythons
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Feb 5, 2024
1 parent 5963169 commit b9c8ac7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docker/install-pythons
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import argparse
import hashlib
import os.path
import platform
import re
import secrets
import subprocess
import sys
Expand Down Expand Up @@ -32,6 +33,16 @@ VERSIONS = ("3.10.13", "3.11.7", "3.12.1")
ARCH_MAP = {"arm64": "aarch64"}
ARCH = ARCH_MAP.get(platform.machine(), platform.machine())

CLANG_PP = re.compile(r"\bclang\+\+")
CLANG = re.compile(r"\bclang\b")


def _must_sub(reg: re.Pattern[str], new: str, s: str) -> str:
after = reg.sub(new, s)
if after == s:
raise AssertionError(f"expected replacement by {reg} => {new}!")
return after


def _checksum_url(version: str) -> tuple[str, str]:
for line in CHECKSUMS.splitlines():
Expand Down Expand Up @@ -79,6 +90,20 @@ def main() -> int:
)
subprocess.check_call(tar_cmd)

# https://github.com/indygreg/python-build-standalone/issues/209
if sys.platform == "linux" and ARCH == "x86_64":
for fname in (
f"{dest}/lib/python{major}.{minor}/config-{major}.{minor}-x86_64-linux-gnu/Makefile",
f"{dest}/lib/python{major}.{minor}/_sysconfigdata__linux_x86_64-linux-gnu.py",
):
print(f"XXX: fixing up build metadata in {fname}")
with open(fname) as f:
contents = f.read()
contents = _must_sub(CLANG_PP, "c++", contents)
contents = _must_sub(CLANG, "cc", contents)
with open(fname, "w") as f:
f.write(contents)

py = os.path.join(dest, "bin", "python3")
subprocess.check_call((py, "-mensurepip"))
subprocess.check_call(
Expand Down

0 comments on commit b9c8ac7

Please sign in to comment.