8000 bpo-43425: Update setup.py not to use distutils.log (GH-26969) · python/cpython@a7e251b · GitHub
[go: up one dir, main page]

Skip to content

Commit a7e251b

Browse files
authored
bpo-43425: Update setup.py not to use distutils.log (GH-26969)
1 parent 0d7f61d commit a7e251b

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

setup.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import importlib._bootstrap
55
import importlib.machinery
66
import importlib.util
7+
import logging
78
import os
89
import re
910
import sys
@@ -44,7 +45,6 @@
4445
DeprecationWarning
4546
)
4647

47-
from distutils import log
4848
from distutils.command.build_ext import build_ext
4949
from distutils.command.build_scripts import build_scripts
5050
from distutils.command.install import install
@@ -64,6 +64,10 @@
6464
LIST_MODULE_NAMES = False
6565

6666

67+
logging.basicConfig(format='%(message)s', level=logging.INFO)
68+
log = logging.getLogger('setup')
69+
70+
6771
def get_platform():
6872
# Cross compiling
6973
if "_PYTHON_HOST_PLATFORM" in os.environ:
@@ -241,6 +245,7 @@ def grep_headers_for(function, headers):
241245
return True
242246
return False
243247

248+
244249
def find_file(filename, std_dirs, paths):
245250
"""Searches for the directory where a given file is located,
246251
and returns a possibly-empty list of additional directories, or None
@@ -259,23 +264,23 @@ def find_file(filename, std_dirs, paths):
259264
sysroot = macosx_sdk_root()
260265

261266
# Check the standard locations
262-
for dir in std_dirs:
263-
f = os.path.join(dir, filename)
267+
for dir_ in std_dirs:
268+
f = os.path.join(dir_, filename)
264269

265-
if MACOS and is_macosx_sdk_path(dir):
266-
f = os.path.join(sysroot, dir[1:], filename)
270+
if MACOS and is_macosx_sdk_path(dir_):
271+
f = os.path.join(sysroot, dir_[1:], filename)
267272

268273
if os.path.exists(f): return []
269274

270275
# Check the additional directories
271-
for dir in paths:
272-
f = os.path.join(dir, filename)
276+
for dir_ in paths:
277+
f = os.path.join(dir_, filename)
273278

274-
if MACOS and is_macosx_sdk_path(dir):
275-
f = os.path.join(sysroot, dir[1:], filename)
279+
if MACOS and is_macosx_sdk_path(dir_):
280+
f = os.path.join(sysroot, dir_[1:], filename)
276281

277282
if os.path.exists(f):
278-
return [dir]
283+
return [dir_]
279284

280285
# Not found anywhere
281286
return None
@@ -333,6 +338,7 @@ def find_library_file(compiler, libname, std_dirs, paths):
333338
else:
334339
assert False, "Internal error: Path not found in std_dirs or paths"
335340

341+
336342
def validate_tzpath():
337343
base_tzpath = sysconfig.get_config_var('TZPATH')
338344
if not base_tzpath:
@@ -345,15 +351,16 @@ def validate_tzpath():
345351
+ f'found:\n{tzpaths!r}\nwith invalid paths:\n'
346352
+ f'{bad_paths!r}')
347353

354+
348355
def find_module_file(module, dirlist):
349356
"""Find a module in a set of possible folders. If it is not found
350357
return the unadorned filename"""
351-
list = find_file(module, [], dirlist)
352-
if not list:
358+
dirs = find_file(module, [], dirlist)
359+
if not dirs:
353360
return module
354-
if len(list) > 1:
355-
log.info("WARNING: multiple copies of %s found", module)
356-
return os.path.join(list[0], module)
361+
if len(dirs) > 1:
362+
log.info(f"WARNING: multiple copies of {module} found")
363+
return os.path.join(dirs[0], module)
357364

358365

359366
class PyBuildExt(build_ext):
@@ -2667,7 +2674,7 @@ def copy_scripts(self):
26672674
newfilename = filename + fullversion
26682675
else:
26692676
newfilename = filename + minoronly
2670-
log.info('renaming %s to %s', filename, newfilename)
2677+
log.info(f'renaming {filename} to {newfilename}')
26712678
os.rename(filename, newfilename)
26722679
newoutfiles.append(newfilename)
26732680
if filename in updated_files:

0 commit comments

Comments
 (0)
0