EN

environment-setup

Provides a reliable procedure for setting up isolated development environments for Python/GIS projects.

Install

mkdir -p .claude/skills/environment-setup && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12293" && unzip -o skill.zip -d .claude/skills/environment-setup && rm skill.zip

Installs to .claude/skills/environment-setup

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Complete setup for uv, GDAL 3.10.3, PostGIS, and all project dependencies. Use when setting up development environment, installing GDAL, or configuring PostGIS backend.
168 chars✓ has a “when” trigger
Beginner

Key capabilities

  • Set up a fully isolated development environment using Conda + uv
  • Install GDAL 3.10.3 and its dependencies
  • Install Python dependencies using uv for speed and determinism
  • Verify the installation of key dependencies like GDAL and GeoPandas
  • Configure optional PostGIS backend setup

How it works

The skill automates the setup of a development environment by using Conda to manage GDAL and other binary dependencies, and uv for fast Python package installation. It ensures isolation to prevent system conflicts.

Inputs & outputs

You give it
A new project repository or a request to set up a development environment
You get back
A configured development environment with uv, GDAL 3.10.3, PostGIS (optional), and project dependencies

When to use environment-setup

  • Setting up a new project environment
  • Installing and configuring GDAL dependencies
  • Configuring PostGIS backends
  • Ensuring reproducible builds across machines

About this skill

Environment Setup

Complete setup for uv, GDAL 3.10.3, PostGIS, and all project dependencies.

Quick Start (Recommended)

For most users, use Conda + uv for a fully isolated environment:

# 1. Clone repository
git clone https://github.com/studentdotai/Nautical-Graph-Toolkit.git
cd Nautical-Graph-Toolkit

# 2. Create Conda environment with GDAL
mamba env update -f environment.yml
conda activate nautical

# 3. Install uv (fast Python package manager)
pip install uv

# 4. Install Python dependencies
uv pip compile requirements.in -o requirements.txt  # Optional: skip to use tested snapshot
uv pip install --no-deps -r requirements.txt

# 5. Install Nautical Graph Toolkit in editable mode
uv pip install -e .

# 6. Verify installation
python -c "from osgeo import gdal; print(f'✓ GDAL {gdal.__version__}')"
pytest tests/core/ -v

Expected output: ✓ GDAL 3.10.3

Purpose

Provide a reliable, reproducible procedure for setting up a complete development environment for the Nautical Graph Toolkit from scratch. This guide focuses on fully isolated environments (Conda or Docker) to avoid system dependency conflicts and ensure cross-platform compatibility.

Prerequisites

  • Conda/Mamba or Docker installed
  • Git installed
  • Terminal/command line access
  • 8+ GB free disk space (5GB for Conda environment, 3GB for data/output)
  • (Optional) PostgreSQL 16+ for PostGIS backend (or use Docker PostGIS)

Why Isolated Environments?

  • No system conflicts: GDAL and GEOS binaries bundled in Conda/Docker
  • Reproducible: Same environment across different machines
  • Cross-platform: Works on Linux, macOS, Windows
  • Clean cleanup: Delete environment/container to remove all traces

Installation Methods

Method 1: Conda + uv (Recommended)

Fully isolated Conda environment with GDAL binaries and uv for fast Python package installation.

Step 1: Clone Repository

git clone https://github.com/studentdotai/Nautical-Graph-Toolkit.git
cd Nautical-Graph-Toolkit

Step 2: Create Conda Environment

# Create environment from environment.yml
mamba env update -f environment.yml

# Activate environment
conda activate nautical

The environment.yml includes:

  • Python 3.11
  • GDAL 3.10.3 (with all GEOS/PROJ dependencies)
  • Other binary dependencies

Step 3: Install uv and Python Dependencies

We use uv for fast, deterministic dependency resolution (preserves GDAL from Conda):

# Install uv (fast Python package manager)
pip install uv

# Compile requirements from requirements.in (optional: skip to use tested snapshot)
uv pip compile requirements.in -o requirements.txt

# Install without dependency resolution
# (--no-deps preserves Conda's binary packages and prevents conflicts)
uv pip install --no-deps -r requirements.txt

# Install Nautical Graph Toolkit in editable mode
uv pip install -e .

Why uv? It's 10-100x faster than pip and prevents accidental GDAL reinstalls that break bindings.

If uv is not available, use pip as fallback:

pip install -r requirements.txt
pip install -e .

Step 4: Verify Installation

# Check key dependencies
python -c "
from osgeo import gdal
import geopandas as gpd
import pandas as pd
print(f'✓ GDAL: {gdal.__version__}')
print(f'✓ GeoPandas: {gpd.__version__}')
print(f'✓ Pandas: {pd.__version__}')
"

# Run unit tests
pytest tests/core/ -v

Method 2: Docker (Alternative)

Fully containerized environment with all dependencies.

Option A: Using Dockerfile (Recommended)

Important: Always pin base image versions for reproducibility:

# Pin specific miniconda version for reproducibility
FROM continuumio/miniconda3:24.1.2-1

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    && rm -rf /var/lib/apt/lists/*

# Create Conda environment with pinned GDAL
COPY environment.yml .
RUN mamba env update -n base -f environment.yml

# Install Python dependencies
COPY requirements.in requirements.txt .
RUN pip install --no-deps -r requirements.txt

WORKDIR /app
COPY . .

CMD ["pytest", "tests/core/", "-v"]

Pinning the base image version ensures your Docker image builds the same way next month.

Build and run:

docker build -t nautical-toolkit .
docker run -it nautical-toolkit

Option B: Docker Compose (with PostGIS)

version: '3.8'
services:
  app:
    build: .
    volumes:
      - .:/app
    depends_on:
      - postgis
    environment:
      - POSTGRES_HOST=postgis
      - POSTGRES_PORT=5432
      - POSTGRES_USER=maritime_user
      - POSTGRES_PASSWORD=secure_pass
      - POSTGRES_DB=maritime_db

  postgis:
    image: postgis/postgis:16-3.4
    environment:
      - POSTGRES_DB=maritime_db
      - POSTGRES_USER=maritime_user
      - POSTGRES_PASSWORD=secure_pass
    ports:
      - "5432:5432"

Run:

docker-compose up -d
docker-compose exec app pytest tests/core/ -v

Optional PostGIS Setup

Only needed for PostGIS backend. See .claude/skills/postgis-setup/ for detailed configuration.

Using System PostgreSQL

# Create database
createdb maritime_db

# Enable PostGIS
psql maritime_db -c "CREATE EXTENSION IF NOT EXISTS postgis;"

# Create .env file
cat > .env <<EOF
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
POSTGRES_DB=maritime_db
EOF

chmod 600 .env

# Verify
psql "host=localhost dbname=maritime_db" -c "SELECT PostGIS_Version();"

Using Docker PostGIS

docker run -d \
    --name postgis \
    -e POSTGRES_DB=maritime_db \
    -e POSTGRES_USER=maritime_user \
    -e POSTGRES_PASSWORD=secure_pass \
    -p 5432:5432 \
    postgis/postgis:16-3.4

# Verify
docker exec postgis psql -U maritime_user -d maritime_db -c "SELECT PostGIS_Version();"

Platform-Specific Notes

Linux

# Install Miniforge (lightweight Conda)
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh

# Then follow Method 1 above

macOS (Intel x86_64)

# Install Miniforge using Homebrew Cask
brew install --cask miniforge

# Then follow Method 1 above

macOS (Apple Silicon M1/M2/M3)

⚠️ Apple Silicon requires special handling. GDAL must compile from source:

# 1. Install native Miniforge for ARM64
# Download from: https://github.com/conda-forge/miniforge/releases
# Look for: Miniforge3-MacOSX-arm64.sh

curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh -o Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh

# 2. Restart terminal or initialize shell
conda init zsh  # or bash

# 3. Follow Method 1 above

Note: GDAL compilation on Apple Silicon may take 5-10 minutes. This is normal.

If you get OSError: dlopen(/path/to/libgdal.dylib):

# Force reinstall GDAL
conda install -c conda-forge gdal=3.10.3 --force-reinstall

Windows

# Download Miniforge installer
# https://github.com/conda-forge/miniforge/releases

# Open Anaconda Prompt and follow Method 1

Common Issues

Issue: Conda Command Not Found

Symptom: conda: command not found or mamba: command not found

Solution:

# Install Miniforge
# Linux: https://github.com/conda-forge/miniforge/releases
# macOS: brew install --cask miniforge
# Windows: Download installer from GitHub

# Initialize shell
conda init bash  # or zsh, fish, etc.
source ~/.bashrc  # Restart shell or source config

Issue: GDAL Version Mismatch

Symptom: GDAL 3.9.x instead of 3.10.3

Solution:

# Pin specific version in environment.yml
# or force reinstall
conda install -c conda-forge gdal=3.10.3 --force-reinstall

Issue: SQLite RTREE Support Missing

Symptom: "no such module: rtree" error during GeoPackage operations

Cause: Conda's sqlite package is not installed or environment not activated.

Solution:

# Verify sqlite is installed from Conda
mamba list | grep sqlite

# Reinstall environment if needed
mamba env update -f environment.yml --prune
mamba activate nautical

Issue: PostgreSQL Connection Refused (Docker)

Symptom: psycopg2.OperationalError: could not connect to server

Solution:

# Check container is running
docker ps | grep postgis

# Check logs
docker logs postgis

# Verify connection
docker exec postgis psql -U maritime_user -d maritime_db -c "SELECT 1;"

Issue: Permission Denied on .env

Symptom: .env file permissions too open

Solution:

chmod 600 .env

Issue: uv Command Not Found

Symptom: uv: command not found

Solution:

# Install uv in Conda environment
conda activate nautical
pip install uv

# Or use pip instead
pip install -r requirements.txt

Verification Checklist

Run these commands to verify your installation:

# [ ] Python version
python --version  # Should be 3.11+

# [ ] GDAL version
python -c "from osgeo import gdal; print(gdal.__version__)"  # Should be 3.10.3

# [ ] Key imports
python -c "
from osgeo import gdal
import geopandas as gpd
import pandas as pd
import networkx as nx
print('✓ All imports successful')
"

# [ ] Unit tests pass
pytest tests/core/ -v

# [ ] (Optional) PostGIS connection
psql "host=localhost dbname=maritime_db" -c "SELECT PostGIS_Version();"

Environment Variables

Create a .env file in the project root for PostGIS configuration:

# PostGIS Connection (required for PostGIS backend)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
POSTGRES_DB=maritime_db

# Optional: GDAL cache size (in bytes)
GDAL_CACHE_MAX=536870912  # 512 MB

Load environment variables in Python:

from dotenv import load_dotenv
load_dotenv()

Reactivating Environment

After closing your terminal or starting a new terminal se


Content truncated.

When not to use it

  • When the user does not need a fully isolated environment
  • When the project does not require GDAL 3.10.3 or PostGIS
  • When the user prefers manual dependency management without uv or Conda

Prerequisites

Conda/Mamba or Docker installedGit installedTerminal/command line access8+ GB free disk space

Limitations

  • Requires Conda/Mamba or Docker for isolation
  • Specifically targets GDAL 3.10.3 and PostGIS
  • Requires 8+ GB free disk space

How it compares

This skill provides a reproducible and isolated environment setup for specific geospatial tools like GDAL and PostGIS, which is more targeted than a general Python environment setup.

Compared to similar skills

environment-setup side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
environment-setup (this skill)06moCautionBeginner
DB Schema Surgeon06moNo flagsAdvanced
drizzle-orm322moNo flagsIntermediate
django-pro204moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry