diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py
index 00f292308df..384bfd3b260 100644
--- a/src/poetry/puzzle/provider.py
+++ b/src/poetry/puzzle/provider.py
@@ -49,6 +49,18 @@
class Indicator(ProgressIndicator):
+ CONTEXT: str | None = None
+
+ @staticmethod
+ def set_context(context: str | None) -> None:
+ Indicator.CONTEXT = context
+
+ def _formatter_context(self) -> str:
+ if Indicator.CONTEXT is None:
+ return " "
+ else:
+ return f": {Indicator.CONTEXT} "
+
def _formatter_elapsed(self) -> str:
elapsed = time.time() - self._start_time
@@ -781,7 +793,9 @@ def progress(self) -> Iterator[None]:
self._io.write_line("Resolving dependencies...")
yield
else:
- indicator = Indicator(self._io, "{message} ({elapsed:2s})")
+ indicator = Indicator(
+ self._io, "{message}{context}({elapsed:2s})"
+ )
with indicator.auto(
"Resolving dependencies...",
diff --git a/src/poetry/utils/helpers.py b/src/poetry/utils/helpers.py
index 0a34cf6e6a6..3aa79a26824 100644
--- a/src/poetry/utils/helpers.py
+++ b/src/poetry/utils/helpers.py
@@ -94,16 +94,41 @@ def download_file(
) -> None:
import requests
+ from poetry.puzzle.provider import Indicator
+
get = requests.get if not session else session.get
response = get(url, stream=True)
response.raise_for_status()
+ set_indicator = False
+ if "Content-Length" in response.headers:
+ try:
+ total_size = int(response.headers["Content-Length"])
+ except ValueError:
+ total_size = 0
+
+ fetched_size = 0
+ last_percent = 0
+
+ Indicator.set_context(f"Downloading {url}")
+ # if less than 1MB, we simply show that we're downloading but skip the updating
+ set_indicator = total_size > 1024 * 1024
+
with open(dest, "wb") as f:
for chunk in response.iter_content(chunk_size=chunk_size):
if chunk:
f.write(chunk)
+ if set_indicator:
+ fetched_size += len(chunk)
+ percent = (fetched_size * 100) // total_size
+ if percent > last_percent:
+ last_percent = percent
+ Indicator.set_context(f"Downloading {url} {percent:3}%")
+
+ Indicator.set_context(None)
+
def get_package_version_display_string(
package: Package, root: Path | None = None