From b6f6ac88b4881c28e49d21a53c461e6174860a2b Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Fri, 2 Feb 2024 20:36:19 +0000 Subject: [PATCH] Remove reference to distutil Distutil has been removed in Python 3.12. Tested by: ``` py -m libcst.tool codemod noop.NOOPCommand .\libcst\tool.py Calculating full-repo metadata... Executing codemod... Finished codemodding 1 files! - Transformed 1 files successfully. - Skipped 0 files. - Failed to codemod 0 files. - 0 warnings were generated. ``` --- libcst/tool.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libcst/tool.py b/libcst/tool.py index 64144cba1..5469ef27d 100644 --- a/libcst/tool.py +++ b/libcst/tool.py @@ -10,11 +10,11 @@ import argparse import dataclasses -import distutils.spawn import importlib import inspect import os import os.path +import shutil import sys import textwrap from abc import ABC, abstractmethod @@ -375,10 +375,7 @@ def _find_and_load_config(proc_name: str) -> Dict[str, Any]: # Make sure that the formatter is findable. if config["formatter"]: - exe = ( - distutils.spawn.find_executable(config["formatter"][0]) - or config["formatter"][0] - ) + exe = shutil.which(config["formatter"][0]) or config["formatter"][0] config["formatter"] = [os.path.abspath(exe), *config["formatter"][1:]] return config