Skip to content

Commit

Permalink
Merge pull request #4721 from jedwards4b/fix/3.12_compatiblity
Browse files Browse the repository at this point in the history
remove remaining distutils references
  • Loading branch information
jedwards4b authored Dec 17, 2024
2 parents 5cd1d07 + 380a930 commit eb274e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CIME/Tools/code_checker
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from CIME.code_checker import check_code, expect
import argparse, sys, os

# pylint: disable=import-error
from distutils.spawn import find_executable
from shutil import which

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,7 +62,7 @@ OR
###############################################################################
def _main_func(description):
###############################################################################
pylint = find_executable("pylint")
pylint = which("pylint")
expect(pylint is not None, "pylint not found")

num_procs, files = parse_command_line(sys.argv, description)
Expand Down
4 changes: 2 additions & 2 deletions CIME/Tools/xmlconvertors/config_pes_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from CIME import utils
from CIME.Tools.standard_script_setup import *
from CIME.utils import run_cmd
from distutils.spawn import find_executable
from shutil import which
import xml.etree.ElementTree as ET
import grid_xml_converter

Expand Down Expand Up @@ -242,7 +242,7 @@ def writexml(self, addlist, newfilename):
root.append(ET.Element("WITH"))
if a is not None:
root.append(a.to_cime5())
xmllint = find_executable("xmllint")
xmllint = which("xmllint")
if xmllint is not None:
run_cmd(
"{} --format --output {} -".format(xmllint, newfilename),
Expand Down
19 changes: 9 additions & 10 deletions CIME/Tools/xmlconvertors/grid_xml_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from CIME import utils
from CIME.Tools.standard_script_setup import *
from CIME.utils import run_cmd_no_fail
from distutils.spawn import find_executable
from shutil import which
import xml.etree.ElementTree as ET
import operator

Expand Down Expand Up @@ -307,6 +307,7 @@ def __init__(self, xmlfilename):
self.n = 0
self.nodes = []
self.populate()
self._xmllint = which(xmllint)

def next(self):
if self.index >= len(self.nodes):
Expand Down Expand Up @@ -358,10 +359,9 @@ def writexml(self, addlist, newfilename):

if a is not None:
grids.append(a.to_cime5())
xmllint = find_executable("xmllint")
if xmllint is not None:
if self._xmllint is not None:
run_cmd_no_fail(
"{} --format --output {} -".format(xmllint, newfilename),
"{} --format --output {} -".format(self._xmllint, newfilename),
input_str=ET.tostring(root),
)

Expand Down Expand Up @@ -392,10 +392,10 @@ def writexml(self, addlist, newfilename):
domains.append(ET.Element("WITH"))
if a is not None:
domains.append(a.to_cime5())
xmllint = find_executable("xmllint")
if xmllint is not None:

if self._xmllint is not None:
run_cmd_no_fail(
"{} --format --output {} -".format(xmllint, newfilename),
"{} --format --output {} -".format(self._xmllint, newfilename),
input_str=ET.tostring(root),
)

Expand All @@ -422,10 +422,9 @@ def writexml(self, addlist, newfilename):
gridmaps.append(ET.Element("WITH"))
if a is not None:
gridmaps.append(a.to_cime5())
xmllint = find_executable("xmllint")
if xmllint is not None:
if self._xmllint is not None:
run_cmd_no_fail(
"{} --format --output {} -".format(xmllint, newfilename),
"{} --format --output {} -".format(self._xmllint, newfilename),
input_str=ET.tostring(root),
)

Expand Down

0 comments on commit eb274e1

Please sign in to comment.