From 7f587167886f1c9e5417f7e622d9737af9409091 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 21 Aug 2025 15:39:15 +0200 Subject: [PATCH] rec: Path.unlink(True) requires python 3.8, rewrite so it works on older versions Signed-off-by: Otto Moerbeek --- pdns/recursordist/rec-rust-lib/generate.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pdns/recursordist/rec-rust-lib/generate.py b/pdns/recursordist/rec-rust-lib/generate.py index d58aba1b77..6488ec80fc 100644 --- a/pdns/recursordist/rec-rust-lib/generate.py +++ b/pdns/recursordist/rec-rust-lib/generate.py @@ -792,6 +792,12 @@ def gen_newstyle_docs(srcdir, argentries): RUNTIME = '*runtime determined*' +def unlinkMissingOK(path): + try: + path.unlink() + except FileNotFoundError: + pass + def generate(): """Read table, validate and generate C++, Rust and .rst files""" srcdir = '.' @@ -841,11 +847,11 @@ def generate(): gen_newstyle_docs(srcdir, entries) # Remove cxx generated files, they need to be re-generated after a table change and the rust dependency tracking does # not do that in some cases. - Path(gendir, 'rust', 'librecrust.a').unlink(True) - Path(gendir, 'rust', 'lib.rs.h').unlink(True) - Path(gendir, 'rust', 'web.rs.h').unlink(True) - Path(gendir, 'rust', 'cxx.h').unlink(True) - Path(gendir, 'rust', 'misc.rs.h').unlink(True) + unlinkMissingOK(Path(gendir, 'rust', 'librecrust.a')) + unlinkMissingOK(Path(gendir, 'rust', 'lib.rs.h')) + unlinkMissingOK(Path(gendir, 'rust', 'web.rs.h')) + unlinkMissingOK(Path(gendir, 'rust', 'cxx.h')) + unlinkMissingOK(Path(gendir, 'rust', 'misc.rs.h')) # Path.walk exists only in very recent versions of Python # With meson, target is in toplevel build dir # With autotools, target exists in rec-rust-lib/rust and this Python script is executed with cwd rec-rust-lib -- 2.47.2