Haricharanpanjwani commented on code in PR #741:
URL: https://github.com/apache/burr/pull/741#discussion_r3115147237


##########
scripts/verify_apache_artifacts.py:
##########
@@ -443,59 +684,295 @@ def verify_licenses(artifacts_dir: str, rat_jar_path: 
str, report_only: bool = F
             f"Apache RAT JAR not found: {rat_jar_path}\nDownload from: 
https://creadur.apache.org/rat/download_rat.cgi";
         )
 
-    # Check for java
     if shutil.which("java") is None:
         _fail("Java not found. Required for Apache RAT.")
 
-    # Find all tar.gz artifacts (not wheels)
-    all_files = [
-        f for f in os.listdir(artifacts_dir) if 
os.path.isfile(os.path.join(artifacts_dir, f))
-    ]
-    tar_artifacts = [f for f in all_files if f.endswith(".tar.gz")]
-
+    tar_artifacts = [name for name in _artifact_files(artifacts_dir) if 
name.endswith(".tar.gz")]
     if not tar_artifacts:
         print(f"⚠️  No tar.gz artifacts found in {artifacts_dir}")
+        summary.fail("Apache RAT", "no tar.gz artifacts found")
         return False
 
     print(f"Found {len(tar_artifacts)} tar.gz artifact(s) to check:\n")
 
     all_valid = True
     for artifact_name in tar_artifacts:
         artifact_path = os.path.join(artifacts_dir, artifact_name)
-
-        # Generate report name from artifact name
         report_name = artifact_name.replace(".tar.gz", "").replace(".", "-")
+        if not _check_licenses_with_rat(
+            artifact_path,
+            rat_jar_path,
+            report_name,
+            summary,
+            report_only,
+        ):
+            all_valid = False
+
+    return all_valid
 
-        if not _check_licenses_with_rat(artifact_path, rat_jar_path, 
report_name, report_only):
+
+def _detect_build_command() -> list[str] | None:
+    build_check = subprocess.run(
+        [sys.executable, "-m", "build", "--version"],
+        capture_output=True,
+        text=True,
+        check=False,
+    )
+    if build_check.returncode == 0:
+        return [sys.executable, "-m", "build"]
+    if shutil.which("flit"):
+        return ["flit"]
+    return None
+
+
+def _release_artifact_map(artifacts_dir: str) -> dict[str, list[str]]:
+    artifacts = _artifact_files(artifacts_dir)
+    return {
+        "source": [name for name in artifacts if name.endswith("-src.tar.gz")],
+        "sdist": [name for name in artifacts if 
name.endswith("-sdist.tar.gz")],
+        "wheel": [name for name in artifacts if name.endswith(".whl")],
+    }
+
+
+def _extract_project_root(source_artifact: str, destination: str) -> Path:
+    with tarfile.open(source_artifact, "r:gz") as tar:
+        _safe_extract_tar(tar, destination)
+
+    entries = [entry for entry in Path(destination).iterdir()]
+    if len(entries) == 1 and entries[0].is_dir():
+        return entries[0]
+    return Path(destination)
+
+
+def _load_apache_release_module(project_root: Path):
+    module_path = project_root / "scripts" / "apache_release.py"
+    spec = importlib.util.spec_from_file_location("apache_release_for_verify", 
module_path)
+    if spec is None or spec.loader is None:
+        raise RuntimeError(f"Unable to load release helper from {module_path}")
+    module = importlib.util.module_from_spec(spec)
+    spec.loader.exec_module(module)
+    return module
+
+
+def _build_reproducible_wheel(project_root: Path, version: str, output_dir: 
str, source_epoch: int) -> tuple[bool, str]:
+    release_module = _load_apache_release_module(project_root)
+    original_env = os.environ.copy()
+    original_cwd = os.getcwd()
+    try:
+        os.environ["SOURCE_DATE_EPOCH"] = str(source_epoch)
+        os.chdir(project_root)
+        wheel_path = release_module._build_wheel_from_current_dir(version, 
output_dir)
+        return True, wheel_path
+    except SystemExit as exc:
+        return False, f"wheel build exited with code {exc.code}"
+    except Exception as exc:
+        return False, str(exc)
+    finally:
+        os.chdir(original_cwd)
+        os.environ.clear()
+        os.environ.update(original_env)
+
+
+def _build_reproducible_artifacts(source_artifact: str, build_tool: list[str], 
output_dir: str) -> tuple[bool, str]:

Review Comment:
   Agreed. I removed the generic `build_tool` path and `_detect_build_command` 
from the reproducible rebuild flow. The verifier now assumes `flit` directly, 
which matches Burr’s actual release build process and keeps the rebuild path 
simpler and more explicit.



-- 
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