Skip to content

Commit

Permalink
Extract context manager for suppressing logs. Ref pypa/distutils#183.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 5, 2022
1 parent 92fc975 commit 2aaa95e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions setuptools/wheel.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Wheels support."""

from distutils.util import get_platform
from distutils import log
import email
import itertools
import os
import posixpath
import re
import zipfile
import contextlib

from distutils.util import get_platform

import pkg_resources
import setuptools
Expand Down Expand Up @@ -50,6 +51,19 @@ def unpack(src_dir, dst_dir):
os.rmdir(dirpath)


@contextlib.contextmanager
def disable_info_traces():
"""
Temporarily disable info traces.
"""
from distutils import log
saved = log.set_threshold(log.WARN)
try:
yield
finally:
log.set_threshold(saved)


class Wheel:

def __init__(self, filename):
Expand Down Expand Up @@ -156,17 +170,12 @@ def raw_req(req):
extras_require=extras_require,
),
)
# Temporarily disable info traces.
log_threshold = log._global_log.threshold
log.set_threshold(log.WARN)
try:
with disable_info_traces():
write_requirements(
setup_dist.get_command_obj('egg_info'),
None,
os.path.join(egg_info, 'requires.txt'),
)
finally:
log.set_threshold(log_threshold)

@staticmethod
def _move_data_entries(destination_eggdir, dist_data):
Expand Down

0 comments on commit 2aaa95e

Please sign in to comment.