Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions MANIFEST.in

This file was deleted.

17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 = []
62 changes: 45 additions & 17 deletions scripts/apache_release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,31 @@ 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}")
return None

# 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:
Expand All @@ -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",
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand All @@ -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
"""
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions scripts/setup_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 " "
Expand Down
Loading