From 20e19b97ee6dc4bb54dc147579599a256bc72989 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 09:16:27 -0800 Subject: [PATCH] Fix NuGet packaging to handle dynamic glibc versions (#8474) * Initial plan * Fix NuGet package to support any glibc version Make mk_nuget_task.py more robust by using pattern matching for glibc versions instead of hardcoding specific versions. This fixes the issue where builds with newer glibc versions (e.g., 2.39) were not recognized, causing the linux-x64 runtime to be missing from the NuGet package. Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Optimize regex patterns with non-capturing groups Use non-capturing groups (?:) instead of capturing groups () for better performance, as the captured groups are not used. Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --- scripts/mk_nuget_task.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/mk_nuget_task.py b/scripts/mk_nuget_task.py index bcbe2be12..80c1f78b5 100644 --- a/scripts/mk_nuget_task.py +++ b/scripts/mk_nuget_task.py @@ -15,6 +15,7 @@ import sys import os.path import shutil import subprocess +import re def mk_dir(d): if not os.path.exists(d): @@ -33,13 +34,29 @@ os_info = { 'x64-ubuntu-latest' : ('so', 'linux-x64'), 'arm64-osx' : ('dylib', 'osx-arm64'), 'debian' : ('so', 'linux-x64') } +# Pattern-based mappings for more flexible matching +# These patterns handle version numbers and other variable parts +os_patterns = [ + (re.compile(r'x64-glibc-\d+(?:\.\d+)*'), 'so', 'linux-x64'), # Matches x64-glibc-2.35, x64-glibc-2.39, etc. + (re.compile(r'arm64-glibc-\d+(?:\.\d+)*'), 'so', 'linux-arm64'), # Matches arm64-glibc-* with version +] + def classify_package(f, arch): + # First try exact matches from the dictionary for os_name in os_info: if os_name in f: ext, dst = os_info[os_name] return os_name, f[:-4], ext, dst + + # Then try pattern-based matching for more flexible version handling + for pattern, ext, dst in os_patterns: + match = pattern.search(f) + if match: + matched_os_name = match.group(0) + return matched_os_name, f[:-4], ext, dst + print("Could not classify", f) return None