Repository: python-poetry/poetry

Issue:
 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.
### Issue Kind

Change in current behaviour

### Description


```
$ python --version
Python 3.12.4
$ poetry --version
Poetry (version 1.8.4)
```

For pandas 2.0.1, there is no wheel file built with Python 3.12.

https://pypi.org/project/pandas/2.0.1/#files

Therefore, poetry tries to build a wheel file with Python 3.12.
But the log only shows "Preparing...", so it is not clear that poetry build a wheel file.
This message alone doesn't tell me why it's taking so long.

```
$ poetry add "pandas=2.0.1"

Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 0 installs, 1 update, 0 removals

  - Downgrading pandas (2.0.3 -> 2.0.1): Preparing...
```

I would like a message like "Building a wheel file" to be output to the log.





### Impact

Once users know what you're building, users can take action, such as changing the version of Pandas you're using.


### Workarounds


When adding the "-vvv" option, the message "Getting build dependencies for wheel..." will be output to the log.


```
$ poetry add "pandas=2.0.1" -vvv

[build:build] Getting build dependencies for wheel...

```


Discussion:
@radoering @yuji38kwmt  I'd like to have a go at it
@yuji38kwmt isn't this already the case? The message "Preparing ..." is shown when a wheel is being prepared (ie. built).

https://github.com/python-poetry/poetry/blob/bd500dd3bdfaec3de6894144c9cedb3a9358be84/src/poetry/installation/executor.py#L587-L610

https://github.com/python-poetry/poetry/blob/bd500dd3bdfaec3de6894144c9cedb3a9358be84/src/poetry/installation/executor.py#L707-L714
Agree with this. Facing a similar issue where I have a slow (7 min) build on a gh actions runner, but even with `-vvv` there's no output to actually tell me which wheel this is.

All I see is
`[build:build] Building wheel...`
> [@yuji38kwmt](https://github.com/yuji38kwmt) isn't this already the case? The message "Preparing ..." is shown when a wheel is being prepared (ie. built).
> 

No, that's not the case.
The message "Preparing ..." alone does not make it clear whether a wheel file is being built.
I thought it was taking time to download the wheel file.
@radoering , @yuji38kwmt , @python-poetry/triage, if this issue hasn't been addressed yet, I would be interested in working on it!



Patch:
diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py
index 03dcc6f93b3..fa2798d89ec 100644
--- a/src/poetry/installation/executor.py
+++ b/src/poetry/installation/executor.py
@@ -34,6 +34,7 @@
 from poetry.utils.helpers import remove_directory
 from poetry.utils.isolated_build import IsolatedBuildBackendError
 from poetry.utils.isolated_build import IsolatedBuildInstallError
+from poetry.utils.log_utils import format_build_wheel_log
 from poetry.vcs.git import Git
 
 
@@ -633,7 +634,7 @@ def _prepare_archive(
 
         message = (
             f"  <fg=blue;options=bold>-</> {operation_message}:"
-            " <info>Preparing...</info>"
+            f"{format_build_wheel_log(package, self._env)}"
         )
         self._write(operation, message)
 
@@ -756,7 +757,7 @@ def _download_link(self, operation: Install | Update, link: Link) -> Path:
         if archive.suffix != ".whl":
             message = (
                 f"  <fg=blue;options=bold>-</> {self.get_operation_message(operation)}:"
-                " <info>Preparing...</info>"
+                f"{format_build_wheel_log(package, self._env)}"
             )
             self._write(operation, message)
 
diff --git a/src/poetry/utils/log_utils.py b/src/poetry/utils/log_utils.py
new file mode 100644
index 00000000000..1838f2048dc
--- /dev/null
+++ b/src/poetry/utils/log_utils.py
@@ -0,0 +1,30 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING
+
+
+if TYPE_CHECKING:
+    from poetry.core.packages.package import Package
+
+    from poetry.utils.env import Env
+
+
+def format_build_wheel_log(package: Package, env: Env) -> str:
+    """Format a log message indicating
+    that a wheel is being built for the given package and environment."""
+    marker_env = env.marker_env
+
+    python_version_info = marker_env.get(
+        "version_info", ("<unknown>", "<unknown>", "<unknown>")
+    )
+    python_version = (
+        f"{python_version_info[0]}.{python_version_info[1]}.{python_version_info[2]}"
+    )
+    platform = marker_env.get("sys_platform", "<unknown-platform>")
+    architecture = marker_env.get("platform_machine", "<unknown-arch>")
+
+    message = (
+        f" <info>Building a wheel file for {package.pretty_name} "
+        f"for Python {python_version} on {platform}-{architecture}</info>"
+    )
+    return message


Test patch:
diff --git a/tests/utils/test_log_utils.py b/tests/utils/test_log_utils.py
new file mode 100644
index 00000000000..eb7c567f8b4
--- /dev/null
+++ b/tests/utils/test_log_utils.py
@@ -0,0 +1,16 @@
+from __future__ import annotations
+
+from poetry.core.packages.package import Package
+
+from poetry.utils.env.mock_env import MockEnv
+from poetry.utils.log_utils import format_build_wheel_log
+
+
+def test_format_build_wheel_log() -> None:
+    env = MockEnv(version_info=(3, 13, 1), platform="win32", platform_machine="AMD64")
+    package = Package(name="demo", version="1.2.3")
+    result = format_build_wheel_log(package, env)
+    expected = (
+        " <info>Building a wheel file for demo for Python 3.13.1 on win32-AMD64</info>"
+    )
+    assert result == expected