Python Package Deployment

The Python package deployment allows you to use Maps4FS directly from Python code with full programmatic control over map generation. This approach is recommended for developers who want to integrate Maps4FS into their own applications or need advanced customization.

Features

🔴 Skill level: Advanced - Recommended for developers 🗺️ Supported map sizes: 2x2, 4x4, 8x8, 16x16 km and any custom size ✂️ Map scaling: Supported ⚙️ Advanced settings: Enabled 🖼️ Texture dissolving: Enabled

System Requirements

  • Python 3.8 or later

  • Git (for source code installation)

  • 8 GB RAM for 2 km maps, 16 GB RAM for 4-8 km maps, 32 GB RAM for larger maps

  • SSD storage (will work very slow on HDD)

  • Windows 10/11 / Linux / MacOS

Step 1: Python Installation

Windows

  1. Download Python:

    • Download the latest Python 3.8+ installer (recommended: Python 3.11 or newer)

    • Choose the "Windows installer (64-bit)" for most users

  2. Install Python:

    • Run the downloaded installer

    • ⚠️ IMPORTANT: Check "Add Python to PATH" during installation

    • Choose "Install Now" or "Customize installation"

    • If customizing, ensure "pip" and "Add Python to environment variables" are selected

  3. Verify installation:

    python --version
    pip --version

    Both commands should return version information.

macOS

  1. Option A: Official Installer (Recommended)

    • Download the latest Python 3.8+ installer

    • Run the .pkg file and follow the installation wizard

  2. Option B: Using Homebrew

  3. Verify installation:

Linux

Ubuntu/Debian:

CentOS/RHEL/Fedora:

Step 2: Git Installation (Optional, for source installation)

Windows

  1. Download and run the installer

  2. Use default settings during installation

  3. Verify: git --version

macOS

Linux

Step 3: Check Prerequisites

Before installing Maps4FS, verify your environment is ready:

Windows Command Prompt or PowerShell:

macOS/Linux Terminal:

All commands should return version information without errors.

Step 4: Create a Project Directory

It's recommended to create a dedicated directory for your Maps4FS project:

Windows:

macOS/Linux:

Step 5: Maps4FS Installation

There are two ways to install Maps4FS as a Python package:

Skill level: 🟡 Beginner-friendly Requires: Python, pip

This is the easiest and most reliable method:

Windows:

macOS/Linux:

Option 2: Install from Source Code (Advanced)

Skill level: 🔴 Advanced developers Requires: Python, pip, Git

For developers who want the latest features or need to modify the source code:

Windows:

macOS/Linux:

💡 Even Easier: Automated Setup Scripts

Maps4FS includes convenient automation scripts that handle all the setup for you:

Windows (PowerShell):

macOS/Linux (Bash):

Benefits of automation scripts:

  • One command setup - No need to remember multiple steps

  • Error handling - Scripts check for prerequisites and handle common issues

  • Consistent environment - Same setup every time

  • Platform optimized - Different scripts for Windows vs Unix systems

  • Time saving - Perfect for quick setup or CI/CD

💡 Pro Tip: Using Visual Studio Code

For the best development experience with source installation:

  1. Install VS Code: Download from code.visualstudio.comarrow-up-right

  2. Open the project:

  3. Install recommended extensions when prompted (Python extension)

  4. Edit and run easily:

    • Open demo.py in VS Code

    • Modify coordinates, map size, or other parameters as needed

    • Press F5 to run with debugger, or Ctrl+F5 to run without debugger

    • The project includes pre-configured launch settings for easy debugging

This approach is perfect for:

  • Experimenting with different settings

  • Learning how Maps4FS works internally

  • Contributing to the project

  • Debugging generation issues

Using a virtual environment is highly recommended to avoid conflicts with other Python packages:

Windows:

macOS/Linux:

Step 6: Download Required Data Templates

Maps4FS requires game templates and schemas to function properly. You need to download these files manually:

  1. Click the green "Code" button"Download ZIP"

  2. Extract the ZIP file and copy the templates folder to your project directory

Download Method 2: Using Git

Required Directory Structure

After downloading, your project directory should look like this:

Verify Templates

Create a simple test script to verify your setup:

Windows (test_setup.py):

Run the test:

Step 7: Your First Map

Now let's create your first map! Create a new Python file called my_first_map.py:

Complete Beginner Example

Run Your First Map

Save the code above as my_first_map.py and run it:

Windows:

macOS/Linux:

Expected Output

You should see output like this:

Advanced Examples

Custom Map Sizes

Different Terrain Providers

Map Rotation

Multiple Maps Generation

Example Files & Learning Resources

📝 demo.py - Your Best Starting Point

➡️ Check out the demo.pyarrow-up-right file in the repository - it's the perfect starting point for learning Maps4FS!

The demo file is a complete, real-world example that includes:

🎯 What's Inside:

  • Complete map generation workflow from start to finish

  • Parameter configuration examples with explanations

  • Progress tracking implementation to see generation status

  • Error handling examples to deal with common issues

  • Multiple coordinate examples for different locations

  • Commented code explaining each step

🚀 How to Use It:

Method 1: Quick Start (PyPI Installation)

Method 2: Full Source Access (Recommended for Learning)

Method 3: VS Code Development (Best for Experimentation)

🔧 Customization Examples:

The demo.py file is designed to be easily modified. Common customizations:

💡 Why Start with demo.py?

  • Tested & Working: It's guaranteed to work if your environment is set up correctly

  • Real Example: Shows actual production-ready code, not just snippets

  • Educational: Learn best practices and proper error handling

  • Customizable: Easy to modify for your specific needs

  • Debugging Ready: If using VS Code, you can step through the code line by line

Troubleshooting

Common Installation Issues

❌ "python is not recognized as an internal or external command"

Problem: Python is not installed or not in your PATH.

Solutions:

  1. Windows: Reinstall Python and ensure "Add Python to PATH" is checked

  2. Alternative: Use the full path: C:\Users\YourName\AppData\Local\Programs\Python\Python311\python.exe

  3. Check installation: Open Control Panel → Programs → Look for Python

❌ "pip is not recognized as an internal or external command"

Problem: pip is not installed or not in PATH.

Solutions:

  1. Windows: Try py -m pip install maps4fs instead of pip install maps4fs

  2. Reinstall Python with pip included

  3. Manual pip installation: Download get-pip.py and run python get-pip.py

❌ "Permission denied" or "Access denied" errors

Problem: Insufficient permissions to install packages.

Solutions:

  1. Windows: Run Command Prompt as Administrator

  2. macOS/Linux: Use pip install --user maps4fs to install for current user only

  3. Use virtual environment: (Recommended) Create a virtual environment first

❌ "No module named 'maps4fs'" after installation

Problem: Package installed in wrong Python environment.

Solutions:

  1. Check Python version: Make sure you're using the same Python where you installed maps4fs

  2. Reinstall: pip uninstall maps4fs then pip install maps4fs

  3. Use virtual environment: Create a clean environment for the project

Common Runtime Issues

❌ "FileNotFoundError: Template file not found"

Problem: Missing game templates.

Solutions:

  1. Download templates: Get the templates folder from the Maps4FS repository

  2. Check structure: Ensure templates are in the correct directory structure

  3. Verify files: Run the test_setup.py script from earlier

❌ "ModuleNotFoundError: No module named 'gdal'" or similar

Problem: Missing system dependencies.

Solutions:

Windows:

macOS:

Linux (Ubuntu/Debian):

❌ "Memory Error" or system freezing during generation

Problem: Insufficient RAM for map size.

Solutions:

  1. Reduce map size: Start with 2048 (2x2 km) instead of larger sizes

  2. Close other applications: Free up RAM before running

  3. Increase virtual memory: (Windows) Increase page file size

  4. Use SSD storage: HDD will be very slow and may cause timeouts

❌ "HTTP Error" or "Connection failed" during DTM download

Problem: Network issues or provider temporarily unavailable.

Solutions:

  1. Check internet connection: Ensure stable internet access

  2. Try different provider: Switch from SRTM30 to ASTER30 or vice versa

  3. Retry later: Providers may have temporary outages

  4. Use cached data: If you've generated maps before, some data may be cached

❌ Map generation takes forever or gets stuck

Problem: Various causes - insufficient resources, network issues, or corrupted data.

Solutions:

  1. Check console output: Look for specific error messages

  2. Monitor resource usage: Task Manager (Windows) or Activity Monitor (macOS)

  3. Restart generation: Sometimes a fresh start helps

  4. Try smaller area: Test with a smaller map size first

Debugging Steps

Step 1: Verify Basic Setup

Step 2: Test Minimal Generation

Performance Optimization

For Faster Generation:

  1. Use smaller map sizes for testing (1024 or 2048)

  2. Use SSD storage instead of HDD

  3. Close unnecessary applications to free up RAM

  4. Use local DTM providers when available (faster than downloading)

For Large Maps:

  1. Ensure sufficient RAM (32GB+ for 16x16 km maps)

  2. Use virtual memory/swap as backup

  3. Generate during low-activity hours

  4. Consider cloud computing for very large maps

Getting Help

Before Asking for Help:

  1. Run the debug scripts above and share the output

  2. Include your system information: OS, Python version, RAM, storage type

  3. Describe your exact steps and what went wrong

  4. Share error messages (full text, not just "it doesn't work")

Where to Get Help:

Quick Reference Commands

Windows:

macOS/Linux:

Last updated