Skip to content

Commit 625b9e8

Browse files
bscottmpkoning2
authored andcommitted
CMAKE: Python distutils obsoleted.
Python 3.12 will not have the distutils package in the standard library. The TextFile class is particularly useful when reading [Mm]akefiles, and recreating its functionality would be painful. Stash a local copy of the last version of distutils.text_file.py and use it. Do not rely on distutils being present or installed.
1 parent dd49f85 commit 625b9e8

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

cmake/generate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import simgen.cmake_container as SCC
2323
import simgen.parse_makefile as SPM
2424
import simgen.packaging as SPKG
25-
## from simgen.text_file import TextFile
2625

2726

2827
def process_makefile(makefile_dir, debug=0):
@@ -189,4 +188,4 @@ def walk_target_deps(target, defs, rules, actions, simulators, depth='', debug=0
189188
## Emit all of the individual CMakeLists.txt
190189
sims.write_simulators(makefile_dir, debug=debug_level)
191190
## Emit the packaging data
192-
SPKG.write_packaging(makefile_dir)
191+
SPKG.write_packaging(makefile_dir)

cmake/simgen/parse_makefile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def parse_makefile(fn, g_vars=None, g_rules=None, g_actions=None):
2323
Collects all of the variable definitions, rules and actions associated with rules.
2424
2525
"""
26-
from distutils.text_file import TextFile
26+
## Python 3.11 and onward dropped distuitls, so import our local copy.
27+
from simgen.text_file import TextFile
28+
2729
fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, errors="surrogateescape")
2830

2931
if g_vars is None:

cmake/simgen/text_file.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
33
provides the TextFile class, which gives an interface to text files
44
that (optionally) takes care of stripping comments, ignoring blank
5-
lines, and joining lines with backslashes.
6-
7-
NOTE: This Python source code is adapted from the distutils module.
8-
Given that the future of distutils is uncertain, keep and maintain
9-
a local copy here.
10-
"""
5+
lines, and joining lines with backslashes."""
116

127
import sys, io
138

0 commit comments

Comments
 (0)