# Migration from Poetry to uv - Summary

This document summarizes the changes made to migrate the armasec project from Poetry to uv.

## Files Changed

### 1. `pyproject.toml`
- **Before**: Used Poetry-specific configuration with `[tool.poetry]` sections
- **After**: Converted to standard Python packaging format using `[project]` section
- **Key changes**:
  - Moved from `[tool.poetry]` to `[project]` for metadata
  - Converted `[tool.poetry.dependencies]` to `dependencies = [...]`
  - Changed `[tool.poetry.extras]` to `[project.optional-dependencies]`
  - Replaced `[tool.poetry.group.dev.dependencies]` with `[dependency-groups]`
  - Updated build system from `poetry-core` to `hatchling`
  - Converted entry points to standard format
  - Added version constraint for httpx to maintain compatibility

### 2. `Makefile`
- **Before**: Used `poetry install` and `poetry run` commands
- **After**: Updated to use `uv sync` and `uv run` commands
- **Key changes**:
  - `poetry install --extras=cli` → `uv sync --group dev`
  - `poetry run <command>` → `uv run <command>`
  - Updated publish target to extract version from pyproject.toml

### 3. GitHub Actions Workflows
Updated all three workflow files:

#### `.github/workflows/test_on_push.yaml`
- **Before**: Used `actions/setup-python@v2` and `Gr1N/setup-poetry@v8`
- **After**: Uses `astral-sh/setup-uv@v2` action
- **Key changes**:
  - Replaced Poetry setup with uv setup
  - Added cache configuration for uv.lock
  - Updated Python installation method

#### `.github/workflows/publish_on_tag.yaml`
- **Before**: Used Poetry for building and publishing
- **After**: Uses uv for building and publishing
- **Key changes**:
  - `poetry build` → `uv build`
  - `poetry publish` → `uv publish --token`
  - Removed Poetry-specific authentication

#### `.github/workflows/build_docs.yaml`
- **Before**: Used Poetry for dependency management
- **After**: Uses uv for dependency management
- **Key changes**:
  - Replaced Poetry setup with uv setup
  - Updated dependency installation command

### 4. Documentation Updates

#### `docs/source/getting_started.md`
- Added uv installation instructions as the primary method
- Kept Poetry and pip instructions for compatibility

#### `docs/source/plugins.md`
- Updated plugin configuration to use standard `[project.entry-points]`
- Added note about legacy Poetry configuration

### 5. New Files Created
- **`uv.lock`**: New lock file generated by uv
- **`.python-version`**: Specifies Python 3.12 for uv's Python management
- **`pyproject.toml.poetry.bak`**: Backup of original Poetry configuration

### 6. Files Removed
- **`poetry.lock`**: Removed old Poetry lock file

## Technical Details

### Dependency Changes
- Maintained all existing dependencies with equivalent version constraints
- Added `httpx<0.28` constraint to maintain test compatibility
- Added `toml` as a dev dependency for the Makefile publish target

### Build System
- Changed from Poetry's custom build backend to Hatchling
- Maintained same package structure and entry points
- Verified that built packages are identical in functionality

### Development Workflow
- All existing make targets work identically
- Tests pass without modification
- Type checking and linting work as before
- Documentation building works as before

## Verification

The following commands were successfully tested:
- `make install` - Dependencies install correctly
- `make test` - All 101 tests pass
- `make qa` - Tests, mypy, and linting all pass
- `uv build` - Package builds successfully
- `uv run armasec --help` - CLI works correctly

## Benefits of Migration

1. **Faster dependency resolution**: uv is significantly faster than Poetry
2. **Better Python version management**: uv can install and manage Python versions
3. **Standard Python packaging**: Uses PEP 517/518 standards instead of Poetry-specific format
4. **Reduced CI complexity**: Simpler GitHub Actions workflows
5. **Future-proof**: Built on standard Python packaging tools

## Compatibility

The migration maintains full backward compatibility:
- Same functionality and API
- Same CLI behavior
- Same package structure
- Same entry points
- Documentation still mentions Poetry as an alternative installation method

## Next Steps

1. Test the migration thoroughly in development environments
2. Update any internal documentation or scripts that reference Poetry
3. Consider removing the Poetry backup file after confirming the migration is successful
4. Update contributor documentation to mention uv as the preferred development tool
