This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 457a2fdd0c Small improvements in package preparation output (#37642)
457a2fdd0c is described below

commit 457a2fdd0c78973213f59f52a005aaf82525d2c5
Author: Jarek Potiuk <[email protected]>
AuthorDate: Fri Feb 23 08:05:15 2024 +0100

    Small improvements in package preparation output (#37642)
    
    Recent change (#37476) added a bit of clutter to the output of the
    release commands and made it a little difficult to see what
    is going on. This PR Fixes those issues:
    
    * stdout,stdeerr from venv creation, pip installation, pip wheel are
      captured and printed on error only
    * check = False is used and retcode check for pip installation which
      gives (potentially) a bit more readable error output
    * list of packages in sdist is displayed after validation for packages
      happen - not before - this way they are nicely summarizing what is
      preparaed.
---
 .../commands/release_management_commands.py        | 35 ++++++++++++++++------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git 
a/dev/breeze/src/airflow_breeze/commands/release_management_commands.py 
b/dev/breeze/src/airflow_breeze/commands/release_management_commands.py
index 7a7e968fec..6cd342bce5 100644
--- a/dev/breeze/src/airflow_breeze/commands/release_management_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/release_management_commands.py
@@ -435,13 +435,13 @@ def _check_sdist_to_wheel_dists(dists_info: 
tuple[DistributionPackageInfo, ...])
             if not venv_created:
                 venv_path = (Path(tmp_dir_name) / ".venv").resolve().absolute()
                 venv_command_result = run_command(
-                    [sys.executable, "-m", "venv", venv_path.__fspath__()],
+                    [sys.executable, "-m", "venv", venv_path.as_posix()],
                     check=False,
                     capture_output=True,
                 )
                 if venv_command_result.returncode != 0:
                     get_console().print(
-                        f"[error]Error when initializing virtualenv in 
{venv_path.__fspath__()}:[/]\n"
+                        f"[error]Error when initializing virtualenv in 
{venv_path.as_posix()}:[/]\n"
                         
f"{venv_command_result.stdout}\n{venv_command_result.stderr}"
                     )
                 python_path = venv_path / "bin" / "python"
@@ -450,8 +450,19 @@ def _check_sdist_to_wheel_dists(dists_info: 
tuple[DistributionPackageInfo, ...])
                         f"\n[errors]Python interpreter is not exist in path 
{python_path}. Exiting!\n"
                     )
                     sys.exit(1)
-                pip_command = (python_path.__fspath__(), "-m", "pip")
-                run_command([*pip_command, "install", 
f"pip=={AIRFLOW_PIP_VERSION}"], check=True)
+                pip_command = (python_path.as_posix(), "-m", "pip")
+                result = run_command(
+                    [*pip_command, "install", f"pip=={AIRFLOW_PIP_VERSION}"],
+                    check=False,
+                    capture_output=True,
+                    text=True,
+                )
+                if result.returncode != 0:
+                    get_console().print(
+                        f"[error]Error when installing pip in 
{venv_path.as_posix()}[/]\n"
+                        f"{result.stdout}\n{result.stderr}"
+                    )
+                    sys.exit(1)
                 venv_created = True
 
             returncode = _check_sdist_to_wheel(di, pip_command, 
str(tmp_dir_name))
@@ -485,6 +496,8 @@ def _check_sdist_to_wheel(dist_info: 
DistributionPackageInfo, pip_command: tuple
         # We should run `pip wheel` outside of Project directory for avoid the 
case
         # when some files presented into the project directory, but not 
included in sdist.
         cwd=cwd,
+        capture_output=True,
+        text=True,
     )
     if (returncode := result_pip_wheel.returncode) == 0:
         get_console().print(
@@ -492,7 +505,8 @@ def _check_sdist_to_wheel(dist_info: 
DistributionPackageInfo, pip_command: tuple
         )
     else:
         get_console().print(
-            f"[error]Unable to build wheel from sdist distribution for package 
{dist_info.package!r}.[/]"
+            f"[error]Unable to build wheel from sdist distribution for package 
{dist_info.package!r}.[/]\n"
+            f"{result_pip_wheel.stdout}\n{result_pip_wheel.stderr}"
         )
     return returncode
 
@@ -526,17 +540,19 @@ def prepare_airflow_packages(
         packages = DistributionPackageInfo.dist_packages(
             package_format=package_format, dist_directory=DIST_DIR, 
build_type="airflow"
         )
+        get_console().print()
+        _check_sdist_to_wheel_dists(packages)
+        get_console().print("\n[info]Packages available in dist:[/]\n")
         for dist_info in packages:
             get_console().print(str(dist_info))
         get_console().print()
-        _check_sdist_to_wheel_dists(packages)
     else:
         _build_airflow_packages_with_docker(
             package_format=package_format,
             source_date_epoch=source_date_epoch,
             version_suffix_for_pypi=version_suffix_for_pypi,
         )
-    get_console().print("[success]Successfully prepared Airflow packages:")
+    get_console().print("[success]Successfully prepared Airflow packages")
 
 
 def provider_action_summary(description: str, message_type: MessageType, 
packages: list[str]):
@@ -859,14 +875,15 @@ def prepare_provider_packages(
         get_console().print("\n[warning]No packages prepared!\n")
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
-    get_console().print("\n[info]Packages available in dist:\n")
     packages = DistributionPackageInfo.dist_packages(
         package_format=package_format, dist_directory=DIST_DIR, 
build_type="providers"
     )
+    get_console().print()
+    _check_sdist_to_wheel_dists(packages)
+    get_console().print("\n[info]Packages available in dist:\n")
     for dist_info in packages:
         get_console().print(str(dist_info))
     get_console().print()
-    _check_sdist_to_wheel_dists(packages)
 
 
 def run_generate_constraints(

Reply via email to