From c0c624d77caeb88330f8047db89b0b65410b41ce Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 08:18:49 -0600 Subject: [PATCH 1/8] Update expat to 2.7.3 --- relenv/build/linux.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index c7e754e6..4b7cb936 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -378,6 +378,22 @@ def build_python(env, dirs, logfp): ] ) + # Patch libexpat + bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" + runcmd(["sed", "-i", 's/^expected_libexpat_tag.*$\expected_libexpat_tag="R_2_7_3"', bash_refresh]) + runcmd(["sed", "-i", 's/^expected_libexpat_ver.*$\expected_libexpat_version="2.7.3"', bash_refresh]) + runcmd(["sed", "-i", 's/^expected_libexpat_sha.*$\expected_libexpat_sha256="821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732"', bash_refresh]) + run_cmd([bash_refresh]) + + print("#" * 80) + expat_root = pathlib.Path(dirs.source) / "Modules" / "expat" + run_cmd(["cat", expat_root / "expat.h"]) + run_cmd(["cat", expat_root / "internal.h"]) + run_cmd(["cat", expat_root / "refresh.sh"]) + run_cmd(["cat", expat_root / "xmlparse.c"]) + run_cmd(["cat", expat_root / "xmlrole.h"]) + print("#" * 80) + if pathlib.Path("setup.py").exists(): with tempfile.NamedTemporaryFile(mode="w", suffix="_patch") as patch_file: patch_file.write(PATCH) From aa2e1a922bfc297ea63f7d3b8853f9f05bd2f1ec Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 09:04:38 -0600 Subject: [PATCH 2/8] Fix pre-commit --- relenv/build/linux.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 4b7cb936..0e3168bc 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -380,9 +380,31 @@ def build_python(env, dirs, logfp): # Patch libexpat bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" - runcmd(["sed", "-i", 's/^expected_libexpat_tag.*$\expected_libexpat_tag="R_2_7_3"', bash_refresh]) - runcmd(["sed", "-i", 's/^expected_libexpat_ver.*$\expected_libexpat_version="2.7.3"', bash_refresh]) - runcmd(["sed", "-i", 's/^expected_libexpat_sha.*$\expected_libexpat_sha256="821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732"', bash_refresh]) + runcmd( + [ + "sed", + "-i", + 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"', + bash_refresh, + ] + ) + runcmd( + [ + "sed", + "-i", + 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"', + bash_refresh, + ] + ) + expat_hash = "821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732" + runcmd( + [ + "sed", + "-i", + f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"', + bash_refresh, + ] + ) run_cmd([bash_refresh]) print("#" * 80) From e16c464ea99860c0348837b8b39387fb8fd9a67e Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 09:18:18 -0600 Subject: [PATCH 3/8] Wrap pathlib in str --- relenv/build/linux.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 0e3168bc..a076d08e 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -385,7 +385,7 @@ def build_python(env, dirs, logfp): "sed", "-i", 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"', - bash_refresh, + str(bash_refresh), ] ) runcmd( @@ -393,7 +393,7 @@ def build_python(env, dirs, logfp): "sed", "-i", 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"', - bash_refresh, + str(bash_refresh), ] ) expat_hash = "821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732" @@ -402,18 +402,18 @@ def build_python(env, dirs, logfp): "sed", "-i", f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"', - bash_refresh, + str(bash_refresh), ] ) run_cmd([bash_refresh]) print("#" * 80) expat_root = pathlib.Path(dirs.source) / "Modules" / "expat" - run_cmd(["cat", expat_root / "expat.h"]) - run_cmd(["cat", expat_root / "internal.h"]) - run_cmd(["cat", expat_root / "refresh.sh"]) - run_cmd(["cat", expat_root / "xmlparse.c"]) - run_cmd(["cat", expat_root / "xmlrole.h"]) + run_cmd(["cat", str(expat_root / "expat.h")]) + run_cmd(["cat", str(expat_root / "internal.h")]) + run_cmd(["cat", str(expat_root / "refresh.sh")]) + run_cmd(["cat", str(expat_root / "xmlparse.c")]) + run_cmd(["cat", str(expat_root / "xmlrole.h")]) print("#" * 80) if pathlib.Path("setup.py").exists(): From 81e8aadd352f865795d8d08d26a2d24fd9eec109 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 09:31:36 -0600 Subject: [PATCH 4/8] Fix sed statement --- relenv/build/linux.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index a076d08e..c3c26ae8 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -384,7 +384,7 @@ def build_python(env, dirs, logfp): [ "sed", "-i", - 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"', + 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"/', str(bash_refresh), ] ) @@ -392,7 +392,7 @@ def build_python(env, dirs, logfp): [ "sed", "-i", - 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"', + 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"/', str(bash_refresh), ] ) @@ -401,19 +401,19 @@ def build_python(env, dirs, logfp): [ "sed", "-i", - f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"', + f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"/', str(bash_refresh), ] ) - run_cmd([bash_refresh]) + runcmd([str(bash_refresh)]) print("#" * 80) expat_root = pathlib.Path(dirs.source) / "Modules" / "expat" - run_cmd(["cat", str(expat_root / "expat.h")]) - run_cmd(["cat", str(expat_root / "internal.h")]) - run_cmd(["cat", str(expat_root / "refresh.sh")]) - run_cmd(["cat", str(expat_root / "xmlparse.c")]) - run_cmd(["cat", str(expat_root / "xmlrole.h")]) + runcmd(["cat", str(expat_root / "expat.h")], stderr=logfp, stdout=logfp) + runcmd(["cat", str(expat_root / "internal.h")], stderr=logfp, stdout=logfp) + runcmd(["cat", str(expat_root / "refresh.sh")], stderr=logfp, stdout=logfp) + runcmd(["cat", str(expat_root / "xmlparse.c")], stderr=logfp, stdout=logfp) + runcmd(["cat", str(expat_root / "xmlrole.h")], stderr=logfp, stdout=logfp) print("#" * 80) if pathlib.Path("setup.py").exists(): From f4d7bad27ff4d2485e552bc697836c758d8dad7e Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 13:21:34 -0600 Subject: [PATCH 5/8] Gate expat update to applicable versions --- relenv/build/linux.py | 85 +++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index c3c26ae8..eb9a6976 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -378,43 +378,50 @@ def build_python(env, dirs, logfp): ] ) - # Patch libexpat - bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" - runcmd( - [ - "sed", - "-i", - 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"/', - str(bash_refresh), - ] - ) - runcmd( - [ - "sed", - "-i", - 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"/', - str(bash_refresh), - ] - ) - expat_hash = "821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732" - runcmd( - [ - "sed", - "-i", - f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"/', - str(bash_refresh), - ] - ) - runcmd([str(bash_refresh)]) - - print("#" * 80) - expat_root = pathlib.Path(dirs.source) / "Modules" / "expat" - runcmd(["cat", str(expat_root / "expat.h")], stderr=logfp, stdout=logfp) - runcmd(["cat", str(expat_root / "internal.h")], stderr=logfp, stdout=logfp) - runcmd(["cat", str(expat_root / "refresh.sh")], stderr=logfp, stdout=logfp) - runcmd(["cat", str(expat_root / "xmlparse.c")], stderr=logfp, stdout=logfp) - runcmd(["cat", str(expat_root / "xmlrole.h")], stderr=logfp, stdout=logfp) - print("#" * 80) + # Patch libexpat on these versions and below + # - 3.10.18 + # - 3.11.13 + # - 3.12.11 + # - 3.13.7 + update_expat = False + relenv_version = Version.parse_string(env["RELENV_PY_MAJOR_VERSION"]) + if relenv_version <= Version.parse_string("3.10.18"): + update_expat = True + elif relenv_version <= Version.parse_string("3.11.13"): + update_expat = True + elif relenv_version <= Version.parse_string("3.12.11"): + update_expat = True + elif relenv_version <= Version.parse_string("3.13.7"): + update_expat = True + + if update_expat: + bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" + runcmd( + [ + "sed", + "-i", + 's/^expected_libexpat_tag.*$/expected_libexpat_tag="R_2_7_3"/', + str(bash_refresh), + ] + ) + runcmd( + [ + "sed", + "-i", + 's/^expected_libexpat_ver.*$/expected_libexpat_version="2.7.3"/', + str(bash_refresh), + ] + ) + expat_hash = "821ac9710d2c073eaf13e1b1895a9c9aa66c1157a99635c639fbff65cdbdd732" + runcmd( + [ + "sed", + "-i", + f's/^expected_libexpat_sha.*$/expected_libexpat_sha256="{expat_hash}"/', + str(bash_refresh), + ] + ) + runcmd([str(bash_refresh)]) if pathlib.Path("setup.py").exists(): with tempfile.NamedTemporaryFile(mode="w", suffix="_patch") as patch_file: @@ -439,9 +446,7 @@ def build_python(env, dirs, logfp): "Modules/Setup", ] ) - if Version.parse_string(env["RELENV_PY_MAJOR_VERSION"]) <= Version.parse_string( - "3.10" - ): + if relenv_version <= Version.parse_string("3.10"): runcmd( [ "sed", From 799c0be8b283cbef3abfe8d18271fea2f6688ea2 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 14:08:01 -0600 Subject: [PATCH 6/8] Fix version comparison --- relenv/build/linux.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index eb9a6976..3af39650 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -379,19 +379,22 @@ def build_python(env, dirs, logfp): ) # Patch libexpat on these versions and below + # - 3.9.23 # - 3.10.18 # - 3.11.13 # - 3.12.11 # - 3.13.7 update_expat = False - relenv_version = Version.parse_string(env["RELENV_PY_MAJOR_VERSION"]) - if relenv_version <= Version.parse_string("3.10.18"): + relenv_version = Version(env["RELENV_PY_MAJOR_VERSION"]) + if relenv_version.minor == 9 and relenv_version.micro <= 23: update_expat = True - elif relenv_version <= Version.parse_string("3.11.13"): + elif relenv_version.minor == 10 and relenv_version.micro <= 18: update_expat = True - elif relenv_version <= Version.parse_string("3.12.11"): + elif relenv_version.minor == 11 and relenv_version.micro <= 13: update_expat = True - elif relenv_version <= Version.parse_string("3.13.7"): + elif relenv_version.minor == 12 and relenv_version.micro <= 11: + update_expat = True + elif relenv_version.minor == 13 and relenv_version.micro <= 7: update_expat = True if update_expat: @@ -446,7 +449,9 @@ def build_python(env, dirs, logfp): "Modules/Setup", ] ) - if relenv_version <= Version.parse_string("3.10"): + if Version.parse_string(env["RELENV_PY_MAJOR_VERSION"]) <= Version.parse_string( + "3.10" + ): runcmd( [ "sed", From 7da02573cd9bb5ffc1bcae0a6a471e0e15beb0c3 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 7 Oct 2025 14:43:07 -0700 Subject: [PATCH 7/8] Refactor libexpat update check --- relenv/build/linux.py | 46 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 3af39650..947ba862 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -342,6 +342,31 @@ def build_krb(env, dirs, logfp): runcmd(["make", "install"], env=env, stderr=logfp, stdout=logfp) +def update_expat(version): + """ + Check if the given python version should get an updated libexpat. + + Patch libexpat on these versions and below: + - 3.9.23 + - 3.10.18 + - 3.11.13 + - 3.12.11 + - 3.13.7 + """ + relenv_version = Version(env["RELENV_PY_MAJOR_VERSION"]) + if relenv_version.minor == 9 and relenv_version.micro <= 23: + return True + elif relenv_version.minor == 10 and relenv_version.micro <= 18: + return True + elif relenv_version.minor == 11 and relenv_version.micro <= 13: + return True + elif relenv_version.minor == 12 and relenv_version.micro <= 11: + return True + elif relenv_version.minor == 13 and relenv_version.micro <= 7: + return True + return False + + def build_python(env, dirs, logfp): """ Run the commands to build Python. @@ -378,26 +403,7 @@ def build_python(env, dirs, logfp): ] ) - # Patch libexpat on these versions and below - # - 3.9.23 - # - 3.10.18 - # - 3.11.13 - # - 3.12.11 - # - 3.13.7 - update_expat = False - relenv_version = Version(env["RELENV_PY_MAJOR_VERSION"]) - if relenv_version.minor == 9 and relenv_version.micro <= 23: - update_expat = True - elif relenv_version.minor == 10 and relenv_version.micro <= 18: - update_expat = True - elif relenv_version.minor == 11 and relenv_version.micro <= 13: - update_expat = True - elif relenv_version.minor == 12 and relenv_version.micro <= 11: - update_expat = True - elif relenv_version.minor == 13 and relenv_version.micro <= 7: - update_expat = True - - if update_expat: + if update_expat(env["RELENV_PY_MAJOR_VERSION"]): bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" runcmd( [ From 9bb82240b85a9357ff0b5fc59d3c03fc016b0db8 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 7 Oct 2025 15:53:06 -0600 Subject: [PATCH 8/8] Pass correct relenv python version --- relenv/build/linux.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 947ba862..ecee6173 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -353,7 +353,7 @@ def update_expat(version): - 3.12.11 - 3.13.7 """ - relenv_version = Version(env["RELENV_PY_MAJOR_VERSION"]) + relenv_version = Version(version) if relenv_version.minor == 9 and relenv_version.micro <= 23: return True elif relenv_version.minor == 10 and relenv_version.micro <= 18: @@ -403,7 +403,7 @@ def build_python(env, dirs, logfp): ] ) - if update_expat(env["RELENV_PY_MAJOR_VERSION"]): + if update_expat(env["RELENV_PY_VERSION"]): bash_refresh = pathlib.Path(dirs.source) / "Modules" / "expat" / "refresh.sh" runcmd( [