This document explains how the AGT Server has been set up as a Python package and how users can install and use it.
The agt_server has been transformed into a proper Python package with the following structure:
agt_server/
├── __init__.py # Package initialization with convenient imports
├── cli.py # Command-line interface for server and dashboard
├── server/ # Tournament server implementation
├── dashboard/ # Web dashboard
├── core/ # Game engine and core logic
├── examples/ # Usage examples
├── pyproject.toml # Modern Python packaging configuration
├── setup.py # Traditional setup configuration
├── MANIFEST.in # Package file inclusion rules
├── requirements.txt # Dependencies
├── install.py # Easy installation script
├── test_package.py # Package verification script
└── README.md # Comprehensive documentation
After installation, users get these commands:
agt-server- Start the tournament serveragt-dashboard- Start the web dashboardagt-dashboard-gui- Start dashboard as GUI application
Users can import and use the package in their Python code:
from agt_server import AGTServer, RPSGame, BOSGame
# Create server
server = AGTServer({"game_type": "rps", "num_rounds": 100})Multiple installation methods:
pip install -e .(development)python install.py(automated installation)pip install .(production)
cd agt_server
python install.pycd agt_server
pip install -e .cd agt_server
pip install .Start Server:
agt-server --game rps --port 8080 --verboseStart Dashboard:
agt-dashboard --port 8081 --server-port 8080Start Both Together:
python -m agt_server.cli both --game rpsBasic Server:
import asyncio
from agt_server import AGTServer
config = {"game_type": "rps", "num_rounds": 100}
server = AGTServer(config, host="localhost", port=8080)
asyncio.run(server.run())Direct Game Usage:
from agt_server import RPSGame, BOSGame
rps = RPSGame(num_rounds=50)
bos = BOSGame(num_rounds=100)- Modern Python packaging standard
- Defines package metadata, dependencies, and entry points
- Entry points create the
agt-serverandagt-dashboardcommands
- Traditional setup configuration for compatibility
- Alternative to pyproject.toml
- Useful for older Python packaging tools
- Controls which files are included in the package
- Excludes test files, documentation, and development artifacts
- Ensures only necessary files are distributed
The package defines these command-line entry points:
[project.scripts]
agt-server = "agt_server.cli:run_server"
agt-dashboard = "agt_server.cli:run_dashboard"
[project.gui-scripts]
agt-dashboard-gui = "agt_server.cli:run_dashboard"This means after installation:
agt-servercommand runsagt_server.cli.run_server()agt-dashboardcommand runsagt_server.cli.run_dashboard()agt-dashboard-guicommand runs the dashboard as a GUI app
The cli.py module provides:
run_server()- Starts the tournament server with command-line argumentsrun_dashboard()- Starts the web dashboardrun_both()- Starts both server and dashboard together- Argument parsing - Comprehensive CLI options for all features
- Error handling - Graceful error handling and user feedback
The __init__.py file provides convenient imports:
# Main classes
from agt_server import AGTServer, GameEngine
# Game classes
from agt_server import RPSGame, BOSGame, ChickenGame, PDGame, LemonadeGame, AuctionGameAfter installation, verify everything works:
python test_package.pyThis script tests:
- Package imports
- Class availability
- Module functionality
- CLI command availability
# Install build tools
pip install build
# Build package
python -m buildpip install dist/agt_server-0.1.0.tar.gz- Import Errors: Make sure you're in the correct directory when installing
- CLI Commands Not Found: Check if the package installed correctly with
pip list - Permission Errors: Use
--userflag or virtual environment - Dependency Issues: Run
python install.pyto install all dependencies
- Check Installation:
pip list | grep agt-server - Test Imports:
python -c "import agt_server; print(agt_server.__version__)" - Test CLI:
agt-server --help - Run Tests:
python test_package.py
After successful installation:
- Start Learning: Run
agt-server --helpto see all options - Try Examples: Run
python examples/basic_usage.py - Run Server: Start with
agt-server --game rps - Use Dashboard: Start with
agt-dashboard - Integrate: Import the package in your own Python projects
When ready to publish:
- Update Version: Modify version in
pyproject.tomlandsetup.py - Build Package:
python -m build - Upload:
twine upload dist/* - Install: Users can then
pip install agt-server
The AGT Server is now a fully-featured Python package that provides:
- ✅ Easy installation and setup
- ✅ Command-line tools for server and dashboard
- ✅ Python API for programmatic use
- ✅ Comprehensive documentation and examples
- ✅ Professional packaging standards
- ✅ Multiple installation methods
- ✅ Easy testing and verification
Users can now install the package and immediately start using it with simple commands like agt-server --game rps or by importing it in their Python code.