Skip to content

Comments

Improve log output when building wheel from source#10404

Merged
radoering merged 12 commits intopython-poetry:mainfrom
rbogart1990:feature/improve-prepare-logging
Jun 7, 2025
Merged

Improve log output when building wheel from source#10404
radoering merged 12 commits intopython-poetry:mainfrom
rbogart1990:feature/improve-prepare-logging

Conversation

@rbogart1990
Copy link
Contributor

@rbogart1990 rbogart1990 commented May 20, 2025

Summary

This PR improves the log output when building a wheel file from source. Previously, the log message showed a generic:

"Preparing..."

This change replaces that message with a more descriptive log line that includes environment-specific details like the Python version, platform, and system architecture. This helps users understand why a package is being built from source (e.g., due to lack of a compatible prebuilt wheel).

Example new output:

Installing regex (2023.12.25): Building a wheel file for regex (no prebuilt wheel available for Python 3.13.1 on win32-AMD64)

Implementation Notes

  • Introduced a new utility function: format_build_wheel_log() in poetry/utils/logging.py
  • Python version, platform, and architecture are extracted from the Env object
  • Fallback values like <unknown> are used if these values can't be resolved.

Open Questions

  • The format of the message (e.g., @unknown-version vs <unknown-version>) is open to feedback if others have a preference.

Pull Request Check List

Resolves: #9865

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Improve wheel build logging by showing detailed environment context when no prebuilt wheel is available.

Enhancements:

  • Replace generic “Preparing…” logs with detailed messages generated by the new format_build_wheel_log utility, showing Python version, platform, and architecture with fallbacks for unknown values

Tests:

  • Add a unit test for format_build_wheel_log to verify its output

@sourcery-ai
Copy link

sourcery-ai bot commented May 20, 2025

Reviewer's Guide

This PR replaces the generic “Preparing…” log messages in wheel‐building workflows with a new descriptive formatter that includes Python version, platform, and architecture (using fallbacks when needed), and adds unit tests for the new utility.

File-Level Changes

Change Details Files
Replaced generic preparation logs with descriptive build-wheel messages
  • Removed hardcoded “Preparing…” in _prepare_archive and _download_link
  • Injected format_build_wheel_log(package, self._env) into the executor’s log output
src/poetry/installation/executor.py
Added format_build_wheel_log utility function
  • Extract Python version, sys_platform, and platform_machine from env.marker_env
  • Build a fallback-capable reason string when no prebuilt wheel is available
  • Return a formatted <info> log line with package name and environment details
src/poetry/utils/logging.py
Introduced unit tests for log formatting
  • Created DummyEnv and DummyPackage to simulate environment markers and package metadata
  • Asserted that format_build_wheel_log returns the expected formatted string
tests/utils/test_logging.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rbogart1990 - I've reviewed your changes - here's some feedback:

  • Consider including package.full_pretty_version in the log output so it shows exactly which version (e.g. demo-1.2.3) is being built.
  • Remove the leading space inside format_build_wheel_log’s return value and let the caller handle spacing to keep formatting consistent.
  • Rename the local variable platform in format_build_wheel_log to avoid shadowing the stdlib module and improve clarity.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rbogart1990
Copy link
Contributor Author

@Secrus , all tests are passing now. The PR is ready for review. Please let me know if you'd like me to make any changes!

Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. It think text for reason has to be adapted somehow + some minor nitpicks regarding the test (see separate comments).

The format of the message (e.g., @unknown-version vs <unknown-version>) is open to feedback if others have a preference.

I prefer <unknown-version>.

@rbogart1990 rbogart1990 requested a review from radoering June 4, 2025 02:41
@radoering radoering merged commit d8bc361 into python-poetry:main Jun 7, 2025
53 checks passed
@rbogart1990 rbogart1990 deleted the feature/improve-prepare-logging branch June 7, 2025 12:33
@github-actions
Copy link

github-actions bot commented Jul 8, 2025

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I want the poetry add command to output information to the log so that it can be seen that the wheel file is being built.

2 participants