Skip to content

Commit 8e5842a

Browse files
committed
Avoid use of the distutils.log module.
1 parent 74652ca commit 8e5842a

32 files changed

+80
-66
lines changed

distutils/_log.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import logging
2+
3+
4+
log = logging.getLogger('distutils')

distutils/_msvccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
LinkError,
3131
)
3232
from .ccompiler import CCompiler, gen_lib_options
33-
from . import log
33+
from ._log import log
3434
from .util import get_platform
3535

3636
from itertools import count

distutils/archive_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .errors import DistutilsExecError
1717
from .spawn import spawn
1818
from .dir_util import mkpath
19-
from . import log
19+
from ._log import log
2020

2121
try:
2222
from pwd import getpwnam

distutils/bcppcompiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .ccompiler import CCompiler, gen_preprocess_options
2626
from .file_util import write_file
2727
from .dep_util import newer
28-
from . import log
28+
from ._log import log
2929

3030

3131
warnings.warn(
@@ -210,7 +210,7 @@ def link( # noqa: C901
210210
)
211211

212212
if runtime_library_dirs:
213-
log.warn(
213+
log.warning(
214214
"I don't know what to do with 'runtime_library_dirs': %s",
215215
str(runtime_library_dirs),
216216
)

distutils/ccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .dir_util import mkpath
2020
from .dep_util import newer_group
2121
from .util import split_quoted, execute
22-
from . import log
22+
from ._log import log
2323

2424

2525
class CCompiler:

distutils/cmd.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import logging
1111

1212
from .errors import DistutilsOptionError
13-
from . import util, dir_util, file_util, archive_util, dep_util, log
13+
from . import util, dir_util, file_util, archive_util, dep_util
14+
from ._log import log
1415

1516

1617
class Command:
@@ -157,14 +158,14 @@ def dump_options(self, header=None, indent=""):
157158

158159
if header is None:
159160
header = "command options for '%s':" % self.get_command_name()
160-
self.announce(indent + header, level=log.INFO)
161+
self.announce(indent + header, level=logging.INFO)
161162
indent = indent + " "
162163
for (option, _, _) in self.user_options:
163164
option = option.translate(longopt_xlate)
164165
if option[-1] == "=":
165166
option = option[:-1]
166167
value = getattr(self, option)
167-
self.announce(indent + "{} = {}".format(option, value), level=log.INFO)
168+
self.announce(indent + "{} = {}".format(option, value), level=logging.INFO)
168169

169170
def run(self):
170171
"""A command's raison d'etre: carry out the action it exists to
@@ -332,7 +333,7 @@ def get_sub_commands(self):
332333
# -- External world manipulation -----------------------------------
333334

334335
def warn(self, msg):
335-
log.warn("warning: %s: %s\n", self.get_command_name(), msg)
336+
log.warning("warning: %s: %s\n", self.get_command_name(), msg)
336337

337338
def execute(self, func, args, msg=None, level=1):
338339
util.execute(func, args, msg, dry_run=self.dry_run)

distutils/command/bdist_dumb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ..dir_util import remove_tree, ensure_relative
1111
from ..errors import DistutilsPlatformError
1212
from ..sysconfig import get_python_version
13-
from distutils import log
13+
from distutils._log import log
1414

1515

1616
class bdist_dumb(Command):

distutils/command/bdist_rpm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
DistutilsExecError,
1818
)
1919
from ..sysconfig import get_python_version
20-
from distutils import log
20+
from distutils._log import log
2121

2222

2323
class bdist_rpm(Command):

distutils/command/build_clib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ..core import Command
1919
from ..errors import DistutilsSetupError
2020
from ..sysconfig import customize_compiler
21-
from distutils import log
21+
from distutils._log import log
2222

2323

2424
def show_compilers():

distutils/command/build_ext.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ..dep_util import newer_group
2323
from ..extension import Extension
2424
from ..util import get_platform
25-
from distutils import log
25+
from distutils._log import log
2626
from . import py37compat
2727

2828
from site import USER_BASE
@@ -373,7 +373,7 @@ def check_extensions_list(self, extensions): # noqa: C901
373373

374374
ext_name, build_info = ext
375375

376-
log.warn(
376+
log.warning(
377377
"old-style (ext_name, build_info) tuple found in "
378378
"ext_modules for extension '%s' "
379379
"-- please convert to Extension instance",
@@ -413,7 +413,9 @@ def check_extensions_list(self, extensions): # noqa: C901
413413
# Medium-easy stuff: same syntax/semantics, different names.
414414
ext.runtime_library_dirs = build_info.get('rpath')
415415
if 'def_file' in build_info:
416-
log.warn("'def_file' element of build info dict " "no longer supported")
416+
log.warning(
417+
"'def_file' element of build info dict " "no longer supported"
418+
)
417419

418420
# Non-trivial stuff: 'macros' split into 'define_macros'
419421
# and 'undef_macros'.
@@ -597,7 +599,7 @@ def swig_sources(self, sources, extension):
597599
# the temp dir.
598600

599601
if self.swig_cpp:
600-
log.warn("--swig-cpp is deprecated - use --swig-opts=-c++")
602+
log.warning("--swig-cpp is deprecated - use --swig-opts=-c++")
601603

602604
if (
603605
self.swig_cpp

0 commit comments

Comments
 (0)