You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hamilton.apache.org by sk...@apache.org on 2026/03/30 19:34:43 UTC

(hamilton) branch release-tooling-fixes updated: Address PR review feedback

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

skrawcz pushed a commit to branch release-tooling-fixes
in repository https://gitbox.apache.org/repos/asf/hamilton.git


The following commit(s) were added to refs/heads/release-tooling-fixes by this push:
     new fcf7835a Address PR review feedback
fcf7835a is described below

commit fcf7835ac1ffe2e1d64f9010baca5d1797b33d1a
Author: Stefan Krawczyk <st...@cs.stanford.edu>
AuthorDate: Mon Mar 30 12:24:32 2026 -0700

    Address PR review feedback
    
    - Fix typo: singed -> signed in release helper
    - Use list unpacking instead of concatenation for files_to_upload
    - Validate exactly 1 tarball/wheel from glob (not just non-empty)
    - Add release dependency group (flit, twine) to pyproject.toml
    - Update README to use uv sync --group release and uv sync --group test
    - Fix grammar and add --clean flag to uv venv in README
    - Add uv run prefix to verify_apache_artifacts.py epilog examples
    - Run ruff format on verify_apache_artifacts.py
---
 pyproject.toml                     |  4 ++++
 scripts/README.md                  | 19 +++++++++----------
 scripts/apache_release_helper.py   | 26 ++++++++++++++------------
 scripts/verify_apache_artifacts.py | 34 ++++++++++++++++++++++------------
 4 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 0db7eb76..90b34a5b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -94,6 +94,10 @@ dev = [
   "prek",
   "ruff==0.15.0", # this should match `.pre-commit-config.yaml`
 ]
+release = [
+  "flit",
+  "twine",
+]
 test = [
   "connectorx; python_version < '3.14'",
   "dask[complete]",
diff --git a/scripts/README.md b/scripts/README.md
index c444b8d0..402cc352 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -20,7 +20,7 @@
 # Policy on source versus distribution
 
 Apache Hamilton is an apache-incubating project. As such, we intend to follow all Apache guidelines to
-both the spirit (and when applicable) the letter.
+both the spirit and (when applicable) the letter.
 
 That said, there is occasional ambiguity. Thus we aim to clarify with a reasonable and consistently maintained
 approach. The question that we found most ambiguous when determining our release process is:
@@ -70,12 +70,12 @@ We recommend using [uv](https://docs.astral.sh/uv/) for Python environment manag
 - Apache RAT jar for license checking (optional, for verification)
 
 ```bash
-# Install uv (if not already installed)
+# Install uv (unless already installed)
 curl -LsSf https://astral.sh/uv/install.sh | sh
 
 # Create a virtual environment with build dependencies
 uv venv --python 3.11
-uv pip install flit twine
+uv sync --group release
 
 # Verify GPG setup
 gpg --list-secret-keys
@@ -171,8 +171,8 @@ All remaining steps assume you are inside the extracted source directory
 
 ```bash
 # Create a fresh environment and install build tools
-uv venv --python 3.11
-uv pip install flit
+uv venv --python 3.11 --clean
+uv sync --group release
 
 # Build the wheel from source
 uv run flit build --no-use-vcs
@@ -184,14 +184,13 @@ uv pip install dist/apache_hamilton-${VERSION}-py3-none-any.whl
 ## Run Tests
 
 ```bash
-# Install test dependencies
-uv pip install pytest pandas numpy typing_extensions typing_inspect
+# Install test dependencies (uses the test dependency group from pyproject.toml)
+uv sync --group test
 
 # Run core unit tests
 uv run pytest tests/ -x -q
 
-# Run plugin tests (requires additional dependencies)
-uv pip install dask graphviz networkx pandera pydantic polars pyarrow scikit-learn
+# Run plugin tests
 uv run pytest plugin_tests/ -x -q
 ```
 
@@ -276,7 +275,7 @@ For local wheel building/testing without signing or the full release process:
 
 ```bash
 uv venv --python 3.11
-uv pip install flit
+uv sync --group release
 
 # Build both sdist and wheel
 uv run flit build --no-use-vcs
diff --git a/scripts/apache_release_helper.py b/scripts/apache_release_helper.py
index 01fa70a9..08ea342d 100644
--- a/scripts/apache_release_helper.py
+++ b/scripts/apache_release_helper.py
@@ -341,35 +341,37 @@ def create_release_artifacts(package_config: dict, version) -> list[str]:
         expected_tar_ball = f"dist/{package_file_name}-{version.lower()}.tar.gz"
         tarball_path = glob.glob(expected_tar_ball)
 
-        if not tarball_path:
+        if len(tarball_path) != 1:
             print(
-                f"Error: Could not find {expected_tar_ball} the generated source tarball in the 'dist' directory."
+                f"Error: Expected exactly 1 tarball matching {expected_tar_ball}, "
+                f"found {len(tarball_path)}."
             )
             if os.path.exists("dist"):
                 print("Contents of 'dist' directory:")
                 for item in os.listdir("dist"):
                     print(f"- {item}")
-            else:
-                print("'dist' directory not found.")
-            raise ValueError("Could not find the generated source tarball in the 'dist' directory.")
+            raise ValueError(f"Could not find the generated source tarball: {expected_tar_ball}")
+        tarball_file = tarball_path[0]
 
         # Copy the tarball to be {package-name}-{version}-incubating-src.tar.gz
         # Use -src suffix to distinguish source distribution from wheel (convenience package)
         new_tar_ball = f"dist/{package_name}-{version.lower()}-incubating-src.tar.gz"
-        _modify_tarball_for_apache_release(tarball_path[0], new_tar_ball, package_name)
+        _modify_tarball_for_apache_release(tarball_file, new_tar_ball, package_name)
         # Remove original flit tarball (only keep the incubating copy)
-        os.remove(tarball_path[0])
+        os.remove(tarball_file)
         archive_name = new_tar_ball
         print(f"Found source tarball: {archive_name}")
-        new_tar_ball_singed = sign_artifacts(archive_name)
-        if new_tar_ball_singed is None:
+        new_tar_ball_signed = sign_artifacts(archive_name)
+        if new_tar_ball_signed is None:
             raise ValueError("Could not sign the main release artifacts.")
 
         # Wheel keeps its original PEP 427 filename (no -incubating suffix)
         expected_wheel = f"dist/{package_file_name}-{version.lower()}-py3-none-any.whl"
         wheel_path = glob.glob(expected_wheel)
-        if not wheel_path:
-            raise ValueError(f"Could not find wheel: {expected_wheel}")
+        if len(wheel_path) != 1:
+            raise ValueError(
+                f"Expected exactly 1 wheel matching {expected_wheel}, found {len(wheel_path)}."
+            )
         wheel_file = wheel_path[0]
 
         # Verify wheel with twine before signing
@@ -378,7 +380,7 @@ def create_release_artifacts(package_config: dict, version) -> list[str]:
 
         wheel_signed_files = sign_artifacts(wheel_file)
 
-        files_to_upload = [new_tar_ball] + new_tar_ball_singed + [wheel_file] + wheel_signed_files
+        files_to_upload = [new_tar_ball, *new_tar_ball_signed, wheel_file, *wheel_signed_files]
         return files_to_upload
 
     finally:
diff --git a/scripts/verify_apache_artifacts.py b/scripts/verify_apache_artifacts.py
index 4ec92949..63da3a6f 100755
--- a/scripts/verify_apache_artifacts.py
+++ b/scripts/verify_apache_artifacts.py
@@ -653,23 +653,23 @@ def main():
         epilog="""
 Examples:
   # List contents of a specific artifact
-  python scripts/verify_apache_artifacts.py list-contents dist/apache-hamilton-0.41.0-incubating-src.tar.gz
-  python scripts/verify_apache_artifacts.py list-contents dist/apache_hamilton-0.41.0-py3-none-any.whl
+  uv run python scripts/verify_apache_artifacts.py list-contents dist/apache-hamilton-0.41.0-incubating-src.tar.gz
+  uv run python scripts/verify_apache_artifacts.py list-contents dist/apache_hamilton-0.41.0-py3-none-any.whl
 
   # Verify signatures and checksums only
-  python scripts/verify_apache_artifacts.py signatures
+  uv run python scripts/verify_apache_artifacts.py signatures
 
   # Verify licenses with Apache RAT
-  python scripts/verify_apache_artifacts.py licenses --rat-jar /path/to/apache-rat.jar
+  uv run python scripts/verify_apache_artifacts.py licenses --rat-jar /path/to/apache-rat.jar
 
   # Verify everything
-  python scripts/verify_apache_artifacts.py all --rat-jar /path/to/apache-rat.jar
+  uv run python scripts/verify_apache_artifacts.py all --rat-jar /path/to/apache-rat.jar
 
   # Report-only mode (don't fail on license issues)
-  python scripts/verify_apache_artifacts.py licenses --rat-jar /path/to/apache-rat.jar --report-only
+  uv run python scripts/verify_apache_artifacts.py licenses --rat-jar /path/to/apache-rat.jar --report-only
 
   # Custom artifacts directory
-  python scripts/verify_apache_artifacts.py all --artifacts-dir /path/to/artifacts --rat-jar /path/to/rat.jar
+  uv run python scripts/verify_apache_artifacts.py all --artifacts-dir /path/to/artifacts --rat-jar /path/to/rat.jar
         """,
     )
 
@@ -686,23 +686,31 @@ Examples:
         "signatures", help="Verify GPG signatures and SHA512 checksums"
     )
     sig_parser.add_argument(
-        "--artifacts-dir", default="dist", help="Directory containing artifacts (default: dist)"
+        "--artifacts-dir",
+        default="dist",
+        help="Directory containing artifacts (default: dist)",
     )
 
     # licenses subcommand
     lic_parser = subparsers.add_parser("licenses", help="Verify licenses with Apache RAT")
     lic_parser.add_argument(
-        "--artifacts-dir", default="dist", help="Directory containing artifacts (default: dist)"
+        "--artifacts-dir",
+        default="dist",
+        help="Directory containing artifacts (default: dist)",
     )
     lic_parser.add_argument("--rat-jar", required=True, help="Path to Apache RAT JAR file")
     lic_parser.add_argument(
-        "--report-only", action="store_true", help="Generate report but don't fail on issues"
+        "--report-only",
+        action="store_true",
+        help="Generate report but don't fail on issues",
     )
 
     # all subcommand
     all_parser = subparsers.add_parser("all", help="Verify everything (signatures + licenses)")
     all_parser.add_argument(
-        "--artifacts-dir", default="dist", help="Directory containing artifacts (default: dist)"
+        "--artifacts-dir",
+        default="dist",
+        help="Directory containing artifacts (default: dist)",
     )
     all_parser.add_argument(
         "--rat-jar", help="Path to Apache RAT JAR file (optional for signatures-only)"
@@ -716,7 +724,9 @@ Examples:
     # twine-check subcommand
     twine_parser = subparsers.add_parser("twine-check", help="Verify wheel metadata with twine")
     twine_parser.add_argument(
-        "--artifacts-dir", default="dist", help="Directory containing artifacts (default: dist)"
+        "--artifacts-dir",
+        default="dist",
+        help="Directory containing artifacts (default: dist)",
     )
 
     args = parser.parse_args()