Skip to content
Draft
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- **Automatic dependency installation** for development environment setup
- Added development dependencies to `pyproject.toml` including pytest, black, flake8, mypy, and pytest-cov
- Created `setup.sh` script for one-command development environment setup
- Created `setup_dev.py` Python script for automated dependency installation and verification
- Added `Makefile` with convenient development commands (test, format, lint, type-check, etc.)
- Created `requirements.txt` and `requirements-dev.txt` for pip-based installation
- Updated README.md with comprehensive development setup instructions
- All setup methods handle externally managed Python environments with `--break-system-packages` flag
- Automatic verification includes package imports, pytest installation, and test suite execution

## [0.6.0] - 2025-01-28

### Added
Expand Down
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Argorator Development Makefile

.PHONY: help install install-dev test test-verbose test-coverage clean format lint type-check

# Default target
help:
@echo "Argorator Development Commands:"
@echo " make install - Install production dependencies"
@echo " make install-dev - Install all dependencies (production + dev)"
@echo " make test - Run tests"
@echo " make test-verbose - Run tests with verbose output"
@echo " make test-coverage - Run tests with coverage report"
@echo " make format - Format code with black"
@echo " make lint - Lint code with flake8"
@echo " make type-check - Type check with mypy"
@echo " make clean - Clean up build artifacts"

# Install production dependencies
install:
pip install -e .

# Install all dependencies including dev tools
install-dev:
pip install -e .[dev]

# Run tests
test:
PYTHONPATH=/workspace/src python3 -m pytest tests/ -q

# Run tests with verbose output
test-verbose:
PYTHONPATH=/workspace/src python3 -m pytest tests/ -v

# Run tests with coverage
test-coverage:
PYTHONPATH=/workspace/src python3 -m pytest tests/ --cov=src/argorator --cov-report=html --cov-report=term

# Format code
format:
python3 -m black src/ tests/

# Lint code
lint:
python3 -m flake8 src/ tests/

# Type check
type-check:
python3 -m mypy src/argorator/

# Clean up
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .pytest_cache/
rm -rf htmlcov/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
64 changes: 62 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,73 @@ argorator script.sh --name John --age 25
- Linux, macOS, or Windows with WSL
- Bash shell

## Development

### Quick Setup

```bash
# Clone the repository
git clone <repository-url>
cd argorator

# Run the automatic setup script
./setup.sh
```

### Manual Setup

```bash
# Install in development mode with all dependencies
pip install -e .[dev]

# Or install step by step
pip install -e . # Install the package
pip install -e .[dev] # Install development dependencies
```

### Development Commands

```bash
# Run tests
make test
# or
PYTHONPATH=/workspace/src python -m pytest tests/

# Run tests with coverage
make test-coverage

# Format code
make format

# Lint code
make lint

# Type checking
make type-check
```

### Alternative Setup Methods

**Using requirements files:**
```bash
pip install -r requirements.txt # Production dependencies
pip install -r requirements-dev.txt # All dependencies
```

**Using Python setup script:**
```bash
python setup_dev.py
```

## Contributing

Want to help improve Argorator?

1. Fork this repository
2. Make your changes
3. Submit a pull request
2. Set up the development environment (see Development section above)
3. Make your changes
4. Run the test suite: `make test`
5. Submit a pull request

We welcome all contributions!

Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ dependencies = [
"parsy>=2.1",
]

[project.optional-dependencies]
dev = [
"pytest>=8.0",
"pytest-cov",
"black",
"flake8",
"mypy",
]

[project.scripts]
argorator = "argorator.cli:main"

Expand Down
7 changes: 7 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Development dependencies
-r requirements.txt
pytest>=8.0
pytest-cov
black
flake8
mypy
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Production dependencies
pydantic>=2.0
parsy>=2.1
79 changes: 79 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Argorator Development Setup Script

set -e # Exit on any error

echo "🚀 Setting up Argorator development environment..."

# Check if Python 3 is available
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is not installed. Please install Python 3.9 or later."
exit 1
fi

# Check Python version
PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
REQUIRED_VERSION="3.9"

if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo "❌ Python $REQUIRED_VERSION or later is required. Found: $PYTHON_VERSION"
exit 1
fi

echo "✅ Python $PYTHON_VERSION detected"

# Check if pip is available
if ! command -v pip3 &> /dev/null; then
echo "❌ pip3 is not installed. Please install pip."
exit 1
fi

echo "✅ pip3 is available"

# Install dependencies
echo "📦 Installing dependencies..."

# Try to install with --break-system-packages if needed
if pip3 install -e .[dev] --break-system-packages 2>/dev/null; then
echo "✅ Dependencies installed successfully"
elif pip3 install -e .[dev]; then
echo "✅ Dependencies installed successfully"
else
echo "❌ Failed to install dependencies"
echo "💡 Try running: pip3 install -e .[dev] --break-system-packages"
exit 1
fi

# Verify installation
echo "🧪 Verifying installation..."

# Test imports
if python3 -c "import argorator; print('✅ Argorator imports successfully')" 2>/dev/null; then
echo "✅ Package imports work"
else
echo "❌ Package import failed"
exit 1
fi

# Run tests
echo "🧪 Running tests..."
if PYTHONPATH=/workspace/src python3 -m pytest tests/ -q; then
echo "✅ All tests pass"
else
echo "⚠️ Some tests failed, but dependencies are installed"
fi

echo ""
echo "🎉 Setup completed successfully!"
echo ""
echo "Next steps:"
echo " • Run tests: PYTHONPATH=/workspace/src python3 -m pytest tests/"
echo " • Run with coverage: PYTHONPATH=/workspace/src python3 -m pytest tests/ --cov=src/argorator"
echo " • Format code: black src/ tests/"
echo " • Lint code: flake8 src/ tests/"
echo ""
echo "Or use the Makefile:"
echo " • make test"
echo " • make test-coverage"
echo " • make format"
echo " • make lint"
105 changes: 105 additions & 0 deletions setup_dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""
Development setup script for Argorator.
Automatically installs dependencies and sets up the development environment.
"""

import subprocess
import sys
import os
from pathlib import Path


def run_command(cmd, description):
"""Run a command and handle errors."""
print(f"🔄 {description}...")
try:
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
print(f"✅ {description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ {description} failed:")
print(f" Command: {cmd}")
print(f" Error: {e.stderr}")
return False


def install_dependencies():
"""Install project dependencies."""
print("🚀 Setting up Argorator development environment...")

# Check if we're in a virtual environment
in_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)

if not in_venv:
print("⚠️ Warning: Not in a virtual environment. Consider creating one:")
print(" python3 -m venv venv")
print(" source venv/bin/activate")
print()

# Install the project in development mode
if not run_command("pip install -e . --break-system-packages", "Installing project in development mode"):
return False

# Install development dependencies
if not run_command("pip install -e .[dev] --break-system-packages", "Installing development dependencies"):
return False

return True


def verify_installation():
"""Verify that the installation works."""
print("\n🧪 Verifying installation...")

# Test imports
try:
import argorator
print("✅ Argorator package imports successfully")
except ImportError as e:
print(f"❌ Failed to import argorator: {e}")
return False

# Test pytest
if not run_command("python3 -m pytest --version", "Checking pytest installation"):
return False

# Run tests
print("\n🧪 Running test suite...")
if not run_command("PYTHONPATH=/workspace/src python3 -m pytest tests/ -q", "Running tests"):
print("⚠️ Some tests failed, but dependencies are installed")
return True

return True


def main():
"""Main setup function."""
# Change to project root
project_root = Path(__file__).parent
os.chdir(project_root)

print("=" * 60)
print("🔧 Argorator Development Setup")
print("=" * 60)

if not install_dependencies():
print("\n❌ Setup failed during dependency installation")
sys.exit(1)

if not verify_installation():
print("\n❌ Setup verification failed")
sys.exit(1)

print("\n" + "=" * 60)
print("🎉 Setup completed successfully!")
print("=" * 60)
print("\nNext steps:")
print("1. Run tests: PYTHONPATH=/workspace/src python -m pytest tests/")
print("2. Run with coverage: PYTHONPATH=/workspace/src python -m pytest tests/ --cov=src/argorator")
print("3. Format code: black src/ tests/")
print("4. Lint code: flake8 src/ tests/")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/argorator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__all__ = ["__version__"]

__version__ = "0.1.0"
__version__ = "0.1.0"
Loading