- Implement llama version command with table and JSON output formats - Add build-time git information capture via scripts/generate_build_info.py - Include comprehensive unit test suite (test_version.py, test_version_simple.py, test_version_integration.py) - Add build system integration with custom setup.py command - Update .gitignore to exclude generated build info file Features: - Display Llama Stack and client versions - Show Python version and build information (git commit, date, branch, tag) - Optional component/provider listing organized by API - Support for both table and JSON output formats - Build-time capture of git metadata for version tracking Testing: - 8 unit tests covering all functionality - Integration tests for CLI execution - Simple dependency-free validation tests - Documentation for test suite and build process Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>
1.5 KiB
Build Scripts
This directory contains scripts used during the build process.
generate_build_info.py
This script generates llama_stack/cli/build_info.py
with hardcoded git information at build time. This ensures that version information is captured at build time rather than being read dynamically at runtime.
Usage
The script is automatically run during the build process via the custom BuildWithBuildInfo
class in setup.py
. You can also run it manually:
python scripts/generate_build_info.py
Generated Information
The script captures the following information:
- Git commit hash (short form)
- Git commit date
- Git branch name
- Git tag (latest)
- Build timestamp
CI/CD Integration
The script handles common CI/CD scenarios:
- Detached HEAD state (common in CI environments)
- Missing git information (fallback to environment variables)
- Git not available (fallback to "unknown" values)
Environment Variables
When running in CI/CD environments where the branch name might not be available via git (detached HEAD), the script checks these environment variables:
GITHUB_REF_NAME
(GitHub Actions)CI_COMMIT_REF_NAME
(GitLab CI)BUILDKITE_BRANCH
(Buildkite)TRAVIS_BRANCH
(Travis CI)
Build Integration
The build info generation is integrated into the build process via:
setup.py
- Custom build command that runs the script before buildingpyproject.toml
- Standard Python package configuration
This ensures that every build includes up-to-date git information without requiring runtime git access.