This is an automated email from the ASF dual-hosted git repository.
skrawcz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hamilton.git
The following commit(s) were added to refs/heads/main by this push:
new b2bee61b Adds flit to build project (#1387)
b2bee61b is described below
commit b2bee61b7c63af9c44114384710cd2e0efecffca
Author: Stefan Krawczyk <[email protected]>
AuthorDate: Sun Sep 28 17:08:58 2025 -0700
Adds flit to build project (#1387)
* Adds flit to build project
We switch to flit on the recommendation of apache airflow.
Note: flit does not handle tuples for versions, so we have
to duplicate this information for now. I have submitted
a PR that they will hopefully accept to fix this.
* Remove manifest.in
Flit does not need this.
* Adds comment about flit
* Updates keys and build script for flit and all the artifacts
---
MANIFEST.in | 20 -------------
pyproject.toml | 17 ++++++++---
scripts/apache_release_helper.py | 62 +++++++++++++++++++++++++++++-----------
scripts/setup_keys.sh | 4 +--
4 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index d34828ff..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include LICENSE
-include NOTICE
-include DISCLAIMER
diff --git a/pyproject.toml b/pyproject.toml
index 172f9634..548fd243 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,12 +16,14 @@
# under the License.
[build-system]
-requires = ["setuptools>=72.1"]
-build-backend = "setuptools.build_meta"
+requires = ["flit_core >=3.11,<4"]
+build-backend = "flit_core.buildapi"
[project]
name = "sf-hamilton"
-dynamic = ["version"]
+version = "1.88.0" # NOTE: keep this in sync with hamilton/version.py
+# TODO: flip back to dynamic once hamilton version is a string. Flit doesn't
handle tuples.
+# dynamic = ["version"]
description = "Hamilton, the micro-framework for creating dataframes."
readme = "README.md"
requires-python = ">=3.8.1, <4"
@@ -174,7 +176,7 @@ docs = [
"xgboost",
]
-[project.entry-points.console_scripts]
+[project.scripts]
h_experiments = "hamilton.plugins.h_experiments.__main__:main"
hamilton = "hamilton.cli.__main__:cli"
hamilton-admin-build-ui = "hamilton.admin:build_ui"
@@ -272,3 +274,10 @@ exclude = ["*tests*"]
[tool.setuptools.package-data]
hamilton = ["*.json", "*.md", "*.txt"]
+
+[tool.flit.module]
+name = "hamilton"
+
+[tool.flit.sdist]
+include = ["LICENSE", "NOTICE", "DISCLAIMER"]
+exclude = []
diff --git a/scripts/apache_release_helper.py b/scripts/apache_release_helper.py
index 55255389..9e509ccc 100644
--- a/scripts/apache_release_helper.py
+++ b/scripts/apache_release_helper.py
@@ -139,17 +139,23 @@ def sign_artifacts(archive_name: str) ->
Optional[list[str]]:
return files
-def create_release_artifacts(version) -> tuple[list[str], list[str]]:
+def create_release_artifacts(version) -> list[str]:
"""Creates the source tarball, GPG signature, and checksums using `python
-m build`."""
print("Creating release artifacts with 'python -m build'...")
-
+ files_to_upload = []
# Clean the dist directory before building.
if os.path.exists("dist"):
shutil.rmtree("dist")
# Use python -m build to create the source distribution.
try:
- subprocess.run(["python", "-m", "build", "--sdist", "."], check=True)
+ subprocess.run(
+ [
+ "flit",
+ "build",
+ ],
+ check=True,
+ )
print("Source distribution created successfully.")
except subprocess.CalledProcessError as e:
print(f"Error creating source distribution: {e}")
@@ -157,6 +163,7 @@ def create_release_artifacts(version) -> tuple[list[str],
list[str]]:
# Find the created tarball in the dist directory.
expected_tar_ball = f"dist/sf_hamilton-{version.lower()}.tar.gz"
+ files_to_upload.append(expected_tar_ball)
tarball_path = glob.glob(expected_tar_ball)
if not tarball_path:
@@ -181,16 +188,38 @@ def create_release_artifacts(version) -> tuple[list[str],
list[str]]:
raise ValueError("Could not sign the main release artifacts.")
# create sf-hamilton release artifacts
sf_hamilton_signed_files = sign_artifacts(expected_tar_ball)
- return [new_tar_ball] + main_signed_files, [expected_tar_ball] +
sf_hamilton_signed_files
-
-
-def svn_upload(version, rc_num, archive_files, sf_hamilton_archive_files,
apache_id):
- """Uploads the artifacts to the ASF dev distribution repository."""
+ # create wheel release artifacts
+ expected_wheel = f"dist/sf_hamilton-{version.lower()}-py3-none-any.whl"
+ wheel_path = glob.glob(expected_wheel)
+ wheel_signed_files = sign_artifacts(wheel_path[0])
+ # create incubator wheel release artifacts
+ expected_incubator_wheel =
f"dist/apache-hamilton-{version.lower()}-incubating-py3-none-any.whl"
+ shutil.copy(wheel_path[0], expected_incubator_wheel)
+ incubator_wheel_signed_files = sign_artifacts(expected_incubator_wheel)
+ files_to_upload = (
+ [new_tar_ball]
+ + main_signed_files
+ + [expected_tar_ball]
+ + sf_hamilton_signed_files
+ + [expected_wheel]
+ + wheel_signed_files
+ + [expected_incubator_wheel]
+ + incubator_wheel_signed_files
+ )
+ return files_to_upload
+
+
+def svn_upload(version, rc_num, files_to_import: list[str], apache_id):
+ """Uploads the artifacts to the ASF dev distribution repository.
+
+ files_to_import: Get the files to import (tarball, asc, sha512).
+ """
print("Uploading artifacts to ASF SVN...")
- svn_path =
f"https://dist.apache.org/repos/dist/dev/incubator/{PROJECT_SHORT_NAME}/apache-hamilton/{version}-incubating-RC{rc_num}"
+ svn_path =
f"https://dist.apache.org/repos/dist/dev/incubator/{PROJECT_SHORT_NAME}/{version}-RC{rc_num}"
try:
# Create a new directory for the release candidate.
+ print(f"Creating directory for {version}-incubating-RC{rc_num}... at
{svn_path}")
subprocess.run(
[
"svn",
@@ -202,9 +231,6 @@ def svn_upload(version, rc_num, archive_files,
sf_hamilton_archive_files, apache
check=True,
)
- # Get the files to import (tarball, asc, sha512).
- files_to_import = archive_files + sf_hamilton_archive_files
-
# Use svn import for the new directory.
for file_path in files_to_import:
subprocess.run(
@@ -220,6 +246,7 @@ def svn_upload(version, rc_num, archive_files,
sf_hamilton_archive_files, apache
],
check=True,
)
+ print(f"Imported {file_path} to {svn_path}")
print(f"Artifacts successfully uploaded to: {svn_path}")
return svn_path
@@ -295,9 +322,9 @@ def main():
"""
### How to Use the Updated Script
- 1. **Install the `build` module**:
+ 1. **Install the `flit` module**:
```bash
- pip install build
+ pip install flit
```
2. **Configure the Script**: Open `apache_release_helper.py` in a text
editor and update the three variables at the top of the file with your
project's details:
* `PROJECT_SHORT_NAME`
@@ -308,6 +335,7 @@ def main():
4. **Run the Script**:
Open your terminal, navigate to the root of your project directory,
and run the script with the desired version, release candidate number, and
Apache ID.
+ Note: if you have multiple gpg keys, specify the default in
~/.gnupg/gpg.conf add a line with `default-key <KEYID>`.
python apache_release_helper.py 1.2.3 0 your_apache_id
"""
@@ -350,13 +378,13 @@ def main():
sys.exit(1)
# Create artifacts
- main_archive_files, sf_hamilton_archive_files =
create_release_artifacts(version)
- if not main_archive_files:
+ files_to_upload = create_release_artifacts(version)
+ if not files_to_upload:
sys.exit(1)
# Upload artifacts
# NOTE: You MUST have your SVN client configured to use your Apache ID and
have permissions.
- svn_url = svn_upload(version, rc_num, main_archive_files,
sf_hamilton_archive_files, apache_id)
+ svn_url = svn_upload(version, rc_num, files_to_upload, apache_id)
if not svn_url:
sys.exit(1)
diff --git a/scripts/setup_keys.sh b/scripts/setup_keys.sh
index 15514bab..334953b1 100755
--- a/scripts/setup_keys.sh
+++ b/scripts/setup_keys.sh
@@ -77,8 +77,8 @@ cd dist/release
svn checkout https://dist.apache.org/repos/dist/release/incubator/hamilton
incubator/hamilton
cd ../../
-gpg --list-keys "$KEY_ID" >> dis/release/incubator/hamilton/KEYS
-cat "$KEY_ID.asc" >> dis/release/incubator/hamilton/KEYS
+gpg --list-keys "$KEY_ID" >> dist/release/incubator/hamilton/KEYS
+cat "$KEY_ID.asc" >> dist/release/incubator/hamilton/KEYS
cd dist/release/incubator/hamilton
echo " "