bpo-43425: Update setup.py not to use distutils.log (GH-26969) · python/cpython@956f1fc (original) (raw)

`@@ -4,6 +4,7 @@

`

4

4

`import importlib._bootstrap

`

5

5

`import importlib.machinery

`

6

6

`import importlib.util

`

``

7

`+

import logging

`

7

8

`import os

`

8

9

`import re

`

9

10

`import sys

`

44

45

`DeprecationWarning

`

45

46

` )

`

46

47

``

47

``

`-

from distutils import log

`

48

48

`from distutils.command.build_ext import build_ext

`

49

49

`from distutils.command.build_scripts import build_scripts

`

50

50

`from distutils.command.install import install

`

`@@ -64,6 +64,10 @@

`

64

64

`LIST_MODULE_NAMES = False

`

65

65

``

66

66

``

``

67

`+

logging.basicConfig(format='%(message)s', level=logging.INFO)

`

``

68

`+

log = logging.getLogger('setup')

`

``

69

+

``

70

+

67

71

`def get_platform():

`

68

72

`# Cross compiling

`

69

73

`if "_PYTHON_HOST_PLATFORM" in os.environ:

`

`@@ -241,6 +245,7 @@ def grep_headers_for(function, headers):

`

241

245

`return True

`

242

246

`return False

`

243

247

``

``

248

+

244

249

`def find_file(filename, std_dirs, paths):

`

245

250

`"""Searches for the directory where a given file is located,

`

246

251

` and returns a possibly-empty list of additional directories, or None

`

`@@ -259,23 +264,23 @@ def find_file(filename, std_dirs, paths):

`

259

264

`sysroot = macosx_sdk_root()

`

260

265

``

261

266

`# 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)

`

264

269

``

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)

`

267

272

``

268

273

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

`

269

274

``

270

275

`# 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)

`

273

278

``

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)

`

276

281

``

277

282

`if os.path.exists(f):

`

278

``

`-

return [dir]

`

``

283

`+

return [dir_]

`

279

284

``

280

285

`# Not found anywhere

`

281

286

`return None

`

`@@ -333,6 +338,7 @@ def find_library_file(compiler, libname, std_dirs, paths):

`

333

338

`else:

`

334

339

`assert False, "Internal error: Path not found in std_dirs or paths"

`

335

340

``

``

341

+

336

342

`def validate_tzpath():

`

337

343

`base_tzpath = sysconfig.get_config_var('TZPATH')

`

338

344

`if not base_tzpath:

`

`@@ -345,15 +351,16 @@ def validate_tzpath():

`

345

351

`+ f'found:\n{tzpaths!r}\nwith invalid paths:\n'

`

346

352

`+ f'{bad_paths!r}')

`

347

353

``

``

354

+

348

355

`def find_module_file(module, dirlist):

`

349

356

`"""Find a module in a set of possible folders. If it is not found

`

350

357

` return the unadorned filename"""

`

351

``

`-

list = find_file(module, [], dirlist)

`

352

``

`-

if not list:

`

``

358

`+

dirs = find_file(module, [], dirlist)

`

``

359

`+

if not dirs:

`

353

360

`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)

`

357

364

``

358

365

``

359

366

`class PyBuildExt(build_ext):

`

`@@ -2667,7 +2674,7 @@ def copy_scripts(self):

`

2667

2674

`newfilename = filename + fullversion

`

2668

2675

`else:

`

2669

2676

`newfilename = filename + minoronly

`

2670

``

`-

log.info('renaming %s to %s', filename, newfilename)

`

``

2677

`+

log.info(f'renaming {filename} to {newfilename}')

`

2671

2678

`os.rename(filename, newfilename)

`

2672

2679

`newoutfiles.append(newfilename)

`

2673

2680

`if filename in updated_files:

`