From 8353bb3e347e6ee74d92f4f537554a68bb7b377c Mon Sep 17 00:00:00 2001 From: Andreas Woess Date: Thu, 10 Oct 2024 17:45:02 +0200 Subject: [PATCH 1/2] Replace pipes.quote with shlex.quote. The pipes module has been removed in Python 3.13. (cherry picked from commit 52d898d8bb6db8728e371d94fc5f87235f1ac202) --- substratevm/mx.substratevm/mx_substratevm.py | 4 ++-- sulong/mx.sulong/mx_sulong.py | 6 +++--- sulong/mx.sulong/mx_sulong_suite_constituents.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index c2b60e1f5d06..7f9bea5d9228 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -32,7 +32,7 @@ from glob import glob from contextlib import contextmanager from os.path import join, exists, dirname -import pipes +import shlex from argparse import ArgumentParser import fnmatch import collections @@ -585,7 +585,7 @@ def dummy_harness(test_deps, vm_launcher, vm_args): unittest_image = native_image(['-ea', '-esa'] + build_args + extra_image_args + [macro_junit + '=' + unittest_file] + svm_experimental_options(['-H:Path=' + junit_test_dir]), env=custom_env) image_pattern_replacement = unittest_image + ".exe" if mx.is_windows() else unittest_image run_args = [arg.replace('${unittest.image}', image_pattern_replacement) for arg in run_args] - mx.log('Running: ' + ' '.join(map(pipes.quote, [unittest_image] + run_args))) + mx.log('Running: ' + ' '.join(map(shlex.quote, [unittest_image] + run_args))) mx.run([unittest_image] + run_args) finally: if not preserve_image: diff --git a/sulong/mx.sulong/mx_sulong.py b/sulong/mx.sulong/mx_sulong.py index 5851ca8e9d6a..6dced01c5ebf 100644 --- a/sulong/mx.sulong/mx_sulong.py +++ b/sulong/mx.sulong/mx_sulong.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # All rights reserved. # @@ -29,7 +29,7 @@ # import sys import os -import pipes +import shlex import tempfile from os.path import join import shutil @@ -166,7 +166,7 @@ def get_jacoco_setting(): def _subst_get_jvm_args(dep): java = mx.get_jdk().java main_class = mx.distribution(dep).mainClass - jvm_args = [pipes.quote(arg) for arg in mx.get_runtime_jvm_args([dep])] + jvm_args = [shlex.quote(arg) for arg in mx.get_runtime_jvm_args([dep])] cmd = [java] + jvm_args + [main_class] return " ".join(cmd) diff --git a/sulong/mx.sulong/mx_sulong_suite_constituents.py b/sulong/mx.sulong/mx_sulong_suite_constituents.py index 45a59e943ee4..4c0479451076 100644 --- a/sulong/mx.sulong/mx_sulong_suite_constituents.py +++ b/sulong/mx.sulong/mx_sulong_suite_constituents.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2023, Oracle and/or its affiliates. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. # # All rights reserved. # @@ -32,7 +32,7 @@ import abc import fnmatch -import pipes +import shlex import mx import mx_cmake @@ -418,7 +418,7 @@ def clean(self, forBuild=False): def contents(self, tool, exe): # platform support all_params = '%*' if mx.is_windows() else '"$@"' - _quote = _quote_windows if mx.is_windows() else pipes.quote + _quote = _quote_windows if mx.is_windows() else shlex.quote # build command line java = mx.get_jdk().java classpath_deps = [dep for dep in self.subject.buildDependencies if isinstance(dep, mx.ClasspathDependency)] From 4a4b5995ec9efa4192e3eac6f6920b376f5c016f Mon Sep 17 00:00:00 2001 From: Andreas Woess Date: Thu, 10 Oct 2024 18:05:54 +0200 Subject: [PATCH 2/2] Fix glob_match on Python 3.13+. (cherry picked from commit 1b0be9e9d1dc550f9199553d2c8ab79f11f1d873) --- sdk/mx.sdk/mx_sdk_shaded.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/mx.sdk/mx_sdk_shaded.py b/sdk/mx.sdk/mx_sdk_shaded.py index e43bd6337676..14e3adf50db3 100644 --- a/sdk/mx.sdk/mx_sdk_shaded.py +++ b/sdk/mx.sdk/mx_sdk_shaded.py @@ -315,8 +315,8 @@ def glob_match(path, pattern): """ assert isinstance(path, PurePath), path if sys.version_info[:2] >= (3, 13): - # Since Python 3.13, PurePath.match already supports '**'. - return path.match(pattern) + # Python 3.13+: PurePath.full_match already supports '**'. + return path.full_match(pattern) pathType = type(path) patternParts = pathType(pattern).parts