Skip to content

Commit

Permalink
Only configure setuptools logging if bdist_wheel is imported
Browse files Browse the repository at this point in the history
Also fix the output of `wheel convert` to add the final "OK" on the same line as the source file name.

Fixes #632.
  • Loading branch information
agronholm committed Nov 7, 2024
1 parent 5b4a98c commit f65bcc2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release Notes
**UNRELEASED**

- Refactored the ``convert`` command to not need setuptools to be installed
- Don't configure setuptools logging unless running ``bdist_wheel``
- Added a redirection from ``wheel.bdist_wheel.bdist_wheel`` to
``setuptools.command.bdist_wheel.bdist_wheel`` to improve compatibility with
``setuptools``' latest fixes.
Expand Down
9 changes: 9 additions & 0 deletions src/wheel/_bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
if TYPE_CHECKING:
import types

# ensure Python logging is configured
try:
__import__("setuptools.logging")
except ImportError:

Check warning on line 40 in src/wheel/_bdist_wheel.py

View check run for this annotation

Codecov / codecov/patch

src/wheel/_bdist_wheel.py#L40

Added line #L40 was not covered by tests
# setuptools < ??
from . import _setuptools_logging

Check warning on line 42 in src/wheel/_bdist_wheel.py

View check run for this annotation

Codecov / codecov/patch

src/wheel/_bdist_wheel.py#L42

Added line #L42 was not covered by tests

_setuptools_logging.configure()

Check warning on line 44 in src/wheel/_bdist_wheel.py

View check run for this annotation

Codecov / codecov/patch

src/wheel/_bdist_wheel.py#L44

Added line #L44 was not covered by tests


def safe_name(name: str) -> str:
"""Convert an arbitrary string to a standard distribution name
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def convert(files: list[str], dest_dir: str, verbose: bool) -> None:
source = WininstFileSource(path)

if verbose:
print(f"{archive}... ", flush=True)
print(f"{archive}... ", flush=True, end="")

Check warning on line 296 in src/wheel/cli/convert.py

View check run for this annotation

Codecov / codecov/patch

src/wheel/cli/convert.py#L296

Added line #L296 was not covered by tests

dest_path = Path(dest_dir) / (
f"{source.name}-{source.version}-{source.pyver}-{source.abi}"
Expand Down
9 changes: 0 additions & 9 deletions src/wheel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@

log = logging.getLogger("wheel")

# ensure Python logging is configured
try:
__import__("setuptools.logging")
except ImportError:
# setuptools < ??
from . import _setuptools_logging

_setuptools_logging.configure()


def urlsafe_b64encode(data: bytes) -> bytes:
"""urlsafe_b64encode without padding"""
Expand Down

0 comments on commit f65bcc2

Please sign in to comment.