This document describes how to build and distribute the Hydra Python extensions using GitHub Actions.
.github/workflows/build-python-artifacts.yml- Main CI workflow that builds the Python extensionsscripts/download_artifacts.py- Helper script to download artifacts from GitHub Actionstest_hydra_module.py- Test script to verify the built module works correctly- Update
CMakeLists.txt- ChangeHYDRA_MODULE_NAMEfrom "HIP" to "Hydra"
Change the module name in your root CMakeLists.txt:
set(HYDRA_MODULE_NAME "Hydra") # Changed from "HIP"# Create the workflow directory
mkdir -p .github/workflows
# Copy the workflow file
cp build-python-artifacts.yml .github/workflows/
# Create scripts directory
mkdir -p scripts
cp download_artifacts.py scripts/
# Commit and push
git add .github/workflows/build-python-artifacts.yml
git add scripts/download_artifacts.py
git add test_hydra_module.py
git commit -m "Add CI/CD for Python extensions with Hydra module name"
git push- Go to your GitHub repository
- Click on the "Actions" tab
- Watch the workflow run
- Builds will create artifacts for:
- Linux (
.sofiles) with CUDA 12.2 and 12.3 - Windows (
.pydfiles) with CUDA 12.2 and 12.3 - Python versions 3.9, 3.10, and 3.11
- Linux (
- Go to Actions tab
- Click on a completed workflow run
- Scroll down to "Artifacts"
- Download the artifacts you need
# Find your run ID from the GitHub Actions page
python scripts/download_artifacts.py --run-id <RUN_ID>
# The script will download all artifacts and create a test script
cd downloaded_artifacts
python test_import.py# List recent workflow runs
gh run list --workflow=build-python-artifacts.yml
# Download all artifacts from a specific run
gh run download <RUN_ID>import sys
sys.path.insert(0, '/path/to/artifact')
import Hydra
print(Hydra.Info())python test_hydra_module.py-
Download the appropriate artifact for your platform:
- Linux:
Hydra-linux-cuda12.2-py3.10/Hydra.so - Windows:
Hydra-windows-cuda1220-py3.10/Hydra.pyd
- Linux:
-
Copy to your project:
# Linux
cp downloaded_artifacts/Hydra-linux-cuda12.2-py3.10/Hydra.so ~/home-media-ai/
# Windows
copy downloaded_artifacts\Hydra-windows-cuda1220-py3.10\Hydra.pyd C:\projects\home-media-ai\- Import in Python:
import Hydra
# Check available functions
info = Hydra.Info()
for cmd in info:
print(cmd.command)
# Use the module
import numpy as np
image = np.random.rand(512, 512).astype(np.float32)
filtered = Hydra.Gaussian(image, sigma=[2.0, 2.0])Artifacts are named with the pattern:
Hydra-{platform}-cuda{version}-py{python_version}
Examples:
Hydra-linux-cuda12.2-py3.10Hydra-windows-cuda1220-py3.11
If you get import errors, check:
- CUDA Runtime: Ensure CUDA 12.x is installed
- Python Version: Match the Python version of the artifact
- Dependencies: Install numpy:
pip install numpy - Library Path: On Linux, you may need to set
LD_LIBRARY_PATH
The module will import but operations may fail if CUDA is not available. This is normal for testing on systems without GPUs.
On Windows, you may need:
- Visual C++ Redistributables
- CUDA Toolkit 12.x
- Ensure
.pydfile is in a directory on your Python path
Once testing is successful:
- Create Wheels: Package as
.whlfiles for pip installation - Conda Package: Create conda recipe for conda-forge submission
- Release Automation: Auto-publish on GitHub releases
After successful testing, we'll:
- Fork conda-forge/staged-recipes
- Add recipe in
recipes/hydra-image-processor/ - Submit PR for review
- Once accepted, get a feedstock repository
- Automatic builds on each release
For issues or questions:
- Check the Actions logs
- Open an issue on the repository
- Check the Hydra website