bugraoz93 commented on code in PR #56456:
URL: https://github.com/apache/airflow/pull/56456#discussion_r2779185430
##########
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:
```suggestion
command = [sys.executable, "-m", "hatch", "build", "-c", "-t",
"custom"]
```
I think `python -m hatch` could solve the issue, maybe the reason it may not
find the CLI in the path for that reason. Hatch is installed over uv env, and
rather maybe Python can reach it for us
--
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]