From a9365fceb72bfc3e0c517c56c833a0c101017ac6 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Nov 2023 14:57:38 -0500 Subject: [PATCH 1/4] stop using deprecated `distutils.dep_util` --- clvm_tools/clvmc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clvm_tools/clvmc.py b/clvm_tools/clvmc.py index c72d625..5b429de 100644 --- a/clvm_tools/clvmc.py +++ b/clvm_tools/clvmc.py @@ -1,7 +1,6 @@ # clvm_tools setuptools integration from distutils import log -from distutils.dep_util import newer import os import pathlib @@ -22,7 +21,9 @@ def compile_clvm_text(text, search_paths): def compile_clvm(input_path, output_path, search_paths=[]): - if newer(input_path, output_path): + input_path = pathlib.Path(input_path) + output_path = pathlib.Path(output_path) + if input_path.stat().st_mtime > output_path.stat().st_mtime: log.info("clvmcc %s -o %s" % (input_path, output_path)) with open(input_path) as f: text = f.read() From 709b5a474fb76dfd90f4edb2eb94dded1a3db6dc Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Nov 2023 15:05:01 -0500 Subject: [PATCH 2/4] handle non-existant output file --- clvm_tools/clvmc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clvm_tools/clvmc.py b/clvm_tools/clvmc.py index 5b429de..501d7ab 100644 --- a/clvm_tools/clvmc.py +++ b/clvm_tools/clvmc.py @@ -23,7 +23,11 @@ def compile_clvm_text(text, search_paths): def compile_clvm(input_path, output_path, search_paths=[]): input_path = pathlib.Path(input_path) output_path = pathlib.Path(output_path) - if input_path.stat().st_mtime > output_path.stat().st_mtime: + try: + output_time = output_path.stat().st_mtime + except distutils.errors.DistutilsFileError: + output_time = None + if output_time is None or input_path.stat().st_mtime > output_time: log.info("clvmcc %s -o %s" % (input_path, output_path)) with open(input_path) as f: text = f.read() From 9bd9d5ce11b4ab047e86f2a92275f75e95101759 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Nov 2023 15:08:02 -0500 Subject: [PATCH 3/4] add the missing import --- clvm_tools/clvmc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clvm_tools/clvmc.py b/clvm_tools/clvmc.py index 501d7ab..3e34c3a 100644 --- a/clvm_tools/clvmc.py +++ b/clvm_tools/clvmc.py @@ -1,6 +1,7 @@ # clvm_tools setuptools integration from distutils import log +from distutils.errors import DistutilsFileError import os import pathlib @@ -25,7 +26,7 @@ def compile_clvm(input_path, output_path, search_paths=[]): output_path = pathlib.Path(output_path) try: output_time = output_path.stat().st_mtime - except distutils.errors.DistutilsFileError: + except DistutilsFileError: output_time = None if output_time is None or input_path.stat().st_mtime > output_time: log.info("clvmcc %s -o %s" % (input_path, output_path)) From 984258aa23517ab161594ade5a8fa9fed83919fd Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Nov 2023 15:09:46 -0500 Subject: [PATCH 4/4] use the right exception... --- clvm_tools/clvmc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clvm_tools/clvmc.py b/clvm_tools/clvmc.py index 3e34c3a..b043d05 100644 --- a/clvm_tools/clvmc.py +++ b/clvm_tools/clvmc.py @@ -1,7 +1,6 @@ # clvm_tools setuptools integration from distutils import log -from distutils.errors import DistutilsFileError import os import pathlib @@ -26,7 +25,7 @@ def compile_clvm(input_path, output_path, search_paths=[]): output_path = pathlib.Path(output_path) try: output_time = output_path.stat().st_mtime - except DistutilsFileError: + except FileNotFoundError: output_time = None if output_time is None or input_path.stat().st_mtime > output_time: log.info("clvmcc %s -o %s" % (input_path, output_path))