potiuk commented on code in PR #56456:
URL: https://github.com/apache/airflow/pull/56456#discussion_r2779202990


##########
dev/breeze/src/airflow_breeze/prepare_providers/provider_distributions.py:
##########
@@ -97,37 +100,60 @@ def build_provider_distribution(
         f"\n[info]Building provider package: {provider_id} "
         f"in format {distribution_format} in 
{target_provider_root_sources_path}\n"
     )
-    command: list[str] = [sys.executable, "-m", "flit", "build", 
"--no-setup-py", "--use-vcs"]
-    get_console().print(
-        "[warning]Workaround wheel-only package bug in flit by building both 
and removing sdist."
-    )
-    # Workaround https://github.com/pypa/flit/issues/743 bug in flit that 
causes .gitignored files
-    # to be included in the package when --format wheel is used
-    remove_sdist = False
-    if distribution_format == "wheel":
-        distribution_format = "both"
-        remove_sdist = True
-    if distribution_format != "both":
-        command.extend(["--format", distribution_format])
-    try:
+    provider_info = get_provider_distributions_metadata().get(provider_id)
+    if not provider_info:
+        raise RuntimeError(f"The provider {provider_id} has no provider.yaml 
defined.")
+    build_backend = provider_info.get("build-system", "flit_core")
+    if build_backend == "flit_core":
+        command: list[str] = [sys.executable, "-m", "flit", "build", 
"--no-setup-py", "--use-vcs"]
+        get_console().print(
+            "[warning]Workaround wheel-only package bug in flit by building 
both and removing sdist."
+        )
+        # Workaround https://github.com/pypa/flit/issues/743 bug in flit that 
causes .gitignored files
+        # to be included in the package when --format wheel is used
+        remove_sdist = False
+        if distribution_format == "wheel":
+            distribution_format = "both"
+            remove_sdist = True
+        if distribution_format != "both":
+            command.extend(["--format", distribution_format])
+        try:
+            run_command(
+                command,
+                check=True,
+                cwd=target_provider_root_sources_path,
+                env={
+                    "SOURCE_DATE_EPOCH": 
str(get_provider_details(provider_id).source_date_epoch),
+                },
+            )
+        except subprocess.CalledProcessError as ex:
+            get_console().print(f"[error]The command returned an error {ex}")
+            raise PrepareReleasePackageErrorBuildingPackageException()
+        if remove_sdist:
+            get_console().print("[warning]Removing sdist file to workaround 
flit bug on wheel-only packages")
+            # Remove the sdist file if it was created
+            package_prefix = "apache_airflow_providers_" + 
provider_id.replace(".", "_")
+            for file in (target_provider_root_sources_path / 
"dist").glob(f"{package_prefix}*.tar.gz"):
+                get_console().print(f"[info]Removing {file} to workaround flit 
bug on wheel-only packages")
+                file.unlink(missing_ok=True)
+    elif build_backend == "hatchling":
+        command = ["hatch", "build", "-c", "-t", "custom"]

Review Comment:
   The issue is that when you run `uv tool install -e ./dev/breeze` , hatch is 
installed as dependency and `uv tool` will only (by design) install the 
executable entrypoint only for the package that is the "main" package being 
installed - not for it's dependencies - so in this case it will only install 
the entrypoint for `breeze` but not for hatch.
   
   This could be solved in two ways:
   
   1) `-m` as suggested by @bugraoz93 
   2) `--with-executables-from hatch` added when `uv tool install` is run. this 
will install the executable entrypoints from hatch
   
   The 1) is better as it is more universal and does not depend on the way how 
environment is created



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to