This guide helps you test the cache functionality on both Linux and Windows laptops before deploying to Docker containers. This ensures compatibility across platforms and identifies platform-specific issues early.
New: The test now automatically tries alternative backends (Kubo, Storacha, S3) via ipfs-kit-py when libp2p-py is not available!
# 1. Run cross-platform test
python test_cross_platform_cache.py
# 2. Review results
# Look for "Platform Compatibility Report" section
# Check "ALTERNATIVE BACKENDS AVAILABLE" if P2P fails
# 3. If tests pass, proceed to Docker testing
# If libp2p fails, use alternative backends (see below)If libp2p-py doesn't work on your platform (common on Windows), the test automatically checks for alternative backends using ipfs-kit-py:
# Install ipfs-kit-py for alternative backends
pip install ipfs-kit-py
# Re-run test to check available backends
python test_cross_platform_cache.py-
Kubo (IPFS) - Local IPFS daemon
# Install IPFS, then: ipfs daemon &
-
Storacha - Cloud storage (web3.storage)
export WEB3_STORAGE_TOKEN=your_token -
S3 - AWS S3 or compatible
export AWS_ACCESS_KEY_ID=your_key export AWS_SECRET_ACCESS_KEY=your_secret export S3_BUCKET=cache
See ALTERNATIVE_BACKENDS_GUIDE.md for detailed setup.
# Update system
sudo apt update && sudo apt upgrade -y
# Install Python 3.8+
sudo apt install python3 python3-pip python3-venv -y
# Install build tools (for P2P dependencies)
sudo apt install build-essential python3-dev -y
# Install Docker (if not already installed)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER# 1. Clone repository
cd ~/projects
git clone <your-repo-url>
cd <repo-name>
# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate
# 3. Install dependencies
pip install --upgrade pip
./install_p2p_cache_deps.sh
# 4. Run cross-platform test
python test_cross_platform_cache.pyPlatform: Linux
Test Results: 11/11 passed
✅ Linux is fully compatible!
Platform-Specific:
- Native libp2p support
- Full P2P functionality
- Docker integration works
- File paths use /
Issue 1: Permission denied on Docker
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back inIssue 2: libp2p build fails
# Install build dependencies
sudo apt install build-essential python3-dev libssl-dev libffi-dev
pip install --upgrade pip setuptools wheel
pip install "libp2p @ git+https://github.com/libp2p/py-libp2p@main"Issue 3: Port already in use
# Check what's using the port
sudo netstat -tulpn | grep 9000
# Kill process or use different port-
Install Python 3.8+
- Download from python.org
- Important: Check "Add Python to PATH" during installation
- Do NOT use Microsoft Store version
-
Install Git for Windows
- Download from git-scm.com
- Use default settings
-
Install Visual Studio Build Tools (for compiling native extensions)
- Download from visualstudio.microsoft.com
- Install "Desktop development with C++"
- OR install standalone:
winget install Microsoft.VisualStudio.2022.BuildTools
-
Install Docker Desktop
- Download from docker.com
- Enable WSL 2 backend (recommended)
# 1. Clone repository
cd C:\Users\<YourUsername>\Projects
git clone <your-repo-url>
cd <repo-name>
# 2. Create virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1
# 3. Upgrade pip
python -m pip install --upgrade pip
# 4. Install dependencies
python -m pip install "libp2p @ git+https://github.com/libp2p/py-libp2p@main" pymultihash>=0.8.2 py-multiformats-cid cryptography
# 5. Run cross-platform test
python test_cross_platform_cache.pyPlatform: Windows
Test Results: 11/11 passed (or 9/11 with warnings)
⚠️ Windows is mostly compatible with some warnings
Platform-Specific:
- libp2p may have limited support
- P2P functionality may be limited
- Docker Desktop required
- File paths use \
Issue 1: "python" not recognized
# Add Python to PATH manually
# 1. Find Python installation: where python
# 2. Add to PATH in System Environment Variables
# OR reinstall Python with "Add to PATH" checkedIssue 2: Execution policy error
# Allow script execution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserIssue 3: libp2p installation fails
# Option A: Use WSL (recommended for full P2P support)
wsl --install
wsl
# Then follow Linux instructions inside WSL
# Option B: Skip P2P, test without it
# Set CACHE_ENABLE_P2P=false
$env:CACHE_ENABLE_P2P="false"
python test_cross_platform_cache.pyIssue 4: Docker Desktop not starting
# Check WSL 2 is installed
wsl --list --verbose
# Update WSL
wsl --update
# Restart Docker DesktopIssue 5: Firewall blocking ports
# Allow Python through firewall
New-NetFirewallRule -DisplayName "Python" -Direction Inbound -Program "C:\...\python.exe" -Action Allow
# OR open specific port
New-NetFirewallRule -DisplayName "Cache P2P" -Direction Inbound -LocalPort 9000 -Protocol TCP -Action AllowTest on both platforms:
# test_basic_cache.py
from ipfs_accelerate_py.github_cli.cache import configure_cache
import tempfile
# Create cache without P2P
cache = configure_cache(
cache_dir=tempfile.mkdtemp(),
enable_p2p=False,
enable_persistence=False
)
# Test operations
cache.put("test", {"data": "value"}, ttl=300)
result = cache.get("test")
print(f"✅ Cache works: {result}")
cache.shutdown()Expected: Works on both Linux and Windows
Test on both platforms:
# test_persistent_cache.py
from ipfs_accelerate_py.github_cli.cache import configure_cache
from pathlib import Path
# Create cache with persistence
cache_dir = Path.home() / ".cache" / "test_cache"
cache_dir.mkdir(parents=True, exist_ok=True)
cache = configure_cache(
cache_dir=str(cache_dir),
enable_p2p=False,
enable_persistence=True
)
# Test operations
cache.put("persistent", {"data": "saved"}, ttl=300)
cache.shutdown()
# Reload
cache2 = configure_cache(
cache_dir=str(cache_dir),
enable_p2p=False,
enable_persistence=True
)
result = cache2.get("persistent")
print(f"✅ Persistence works: {result}")
cache2.shutdown()Expected: Works on both platforms
Test on Linux (should work):
python test_cross_platform_cache.py
# Look for "P2P support available: True"Test on Windows (may not work):
python test_cross_platform_cache.py
# May show "P2P support available: False"
# This is OK - use cache without P2P on WindowsUse the dedicated two-machine smoke tool:
Quickstart (recommended):
- On both laptops:
export GITHUB_REPOSITORY=owner/repo
export CACHE_P2P_SHARED_SECRET='replace-with-a-random-shared-secret'- Laptop B (reader):
export CACHE_LISTEN_PORT=9101
python tools/github_p2p_cache_smoke.py --read --target octocat/Hello-World --wait-seconds 120 --verbose- Laptop A (writer):
export CACHE_LISTEN_PORT=9100
python tools/github_p2p_cache_smoke.py --write --target octocat/Hello-World --verboseNotes:
- If
connected_peersstays 0 on the writer, inbound firewall/NAT is the usual culprit. - For same-host multi-process testing, use
IPFS_ACCELERATE_P2P_CACHE_DIR+ uniqueRUNNER_NAMEand setIPFS_ACCELERATE_P2P_FORCE_LOCALHOST=1.
- Python 3.8+ installed
- Virtual environment created
- Dependencies installed (including libp2p)
- Cross-platform test passes (11/11)
- P2P cache initializes
- Can bind to network ports
- Docker installed and user in docker group
- Python 3.8+ installed (from python.org)
- Virtual environment created
- Dependencies installed (cryptography at minimum)
- Cross-platform test passes (9/11 or better)
- Basic cache works (without P2P is OK)
- File operations work
- Docker Desktop installed and running
- Can create/read/write files
- Can bind to network ports
- Environment variables work
- AnyIO works
- Path operations work
-
Test Docker Locally (on each platform)
# Linux docker run --network host -e CACHE_ENABLE_P2P=true your-image # Windows (Docker Desktop) docker run --network host -e CACHE_ENABLE_P2P=false your-image
-
Test Docker to Host Communication
- Linux: Test with
--network host - Windows: Test with bridge network (P2P may not work)
- Linux: Test with
-
Deploy to CI/CD
- Use findings from local tests
- Configure based on platform constraints
Check:
- Python version >= 3.8
- Virtual environment activated
- Dependencies installed correctly
- No firewall blocking
Solution:
# Reinstall everything
rm -rf venv # On Linux
# OR
Remove-Item -Recurse -Force venv # On Windows
# Start fresh
python -m venv venv
source venv/bin/activate # Linux
# OR
.\venv\Scripts\Activate.ps1 # Windows
pip install --upgrade pip
pip install -r requirements.txtMost Common Issue: libp2p compatibility
Solution:
- Accept P2P won't work on Windows
- Test without P2P:
$env:CACHE_ENABLE_P2P="false" - Use WSL for full compatibility (recommended)
Check:
- Docker daemon running
- Network mode correct
- Environment variables passed to container
- Ports not blocked by firewall
Solution: See DOCKER_CACHE_QUICK_START.md
| Feature | Linux | Windows | WSL | Docker |
|---|---|---|---|---|
| Basic Cache | ✅ | ✅ | ✅ | ✅ |
| File Operations | ✅ | ✅ | ✅ | ✅ |
| Network Ops | ✅ | ✅ | ✅ | ✅ |
| P2P Cache | ✅ | ✅ | ✅ | |
| libp2p | ✅ | ❌/ |
✅ | ✅ |
| Docker Integration | ✅ | ✅ | ✅ | N/A |
Recommendation:
- Linux: Use natively, full features work
- Windows: Use WSL for development, or test without P2P
- Production: Deploy with Docker (Linux containers)
- Run test:
python test_cross_platform_cache.py - Check results: Review "Platform Compatibility Report"
- Platform issues: See platform-specific sections above
- Docker issues: See DEPLOYMENT_GUIDE.md