Skip to main content

Build Status PyPI Python Version License

pyciv7

Python bindings for the Sid Meier’s Civilization VII SDK.

Easily build, validate, and package Civilization 7 mods using Python instead of hand-writing .modinfo XML.

Features

  • High-level mod definition: Define your mods in Pydantic models and export .modinfo XML automatically.
  • Validation & recommendations: Get warnings when mod metadata is missing or incorrectly formatted.
  • SQLAlchemy integration: Embed SQLAlchemy queries directly into your mods instead of writing raw SQL files.
  • Settings auto-detection: Automatically detects Civ7 installation and settings directories across Windows, macOS, and Linux.

Quick Example

import pyciv7
from pyciv7.modinfo import *
from sqlalchemy import text

sql_statement = text(
    "INSERT INTO Types"
    "\n        (Type,                              Kind)"
    "\nVALUES  ('TRADITION_FXS_CYLINDER_SEALS',    'KIND_TRADITION');"
    "\n"
    "\nINSERT INTO TraditionModifiers"
    "\n  ("
    "\n   TraditionType,"
    "\n   ModifierId"
    "\n  )"
    "\nVALUES ("
    "\n   'TRADITION_PANJI',"
    "\n   'MOD_FXS_TRADITION_PANJI_QUARTER_CULTURE'"
    "\n  ),"
    "\n  ("
    "\n   'TRADITION_PANJI',"
    "\n   'MOD_FXS_TRADITION_PANJI_QUARTER_CULTURE_ISLAND'"
    "\n  );"
)

mod = Mod(
    id="fxs-new-policies",
    version="1",
    properties=Properties(
        name="Antiquity Policies",
        description="Adds new policies to the Antiquity Age",
        authors="Firaxis",
        affects_saved_games=True,
    ),
    action_criteria=[
        Criteria(
            id="antiquity-age-current",
            conditions=[AgeInUse(age="AGE_ANTIQUITY")],
        )
    ],
    action_groups=[
        ActionGroup(
            id="antiquity-game",
            scope="game",
            criteria="antiquity-age-current",
            # Items can still be a relative path to a SQL/XML file
            actions=[UpdateDatabase(items=[sql_statement])],
        )
    ],
)

# If you want to use a dictionary instead of importing all the models, you can also do
# Mod.model_validate({"id": "fxs-new-policies", "properties": {"name": "Antiquity Policies"}, ... etc.})
pyciv7.build(mod)

This Python snippet produces a .modinfo XML similar to the SDK's "Getting Started" example:

<Mod id="fxs-new-policies" version="1" xmlns="ModInfo">
    <Properties>
        <Name>Antiquity Policies</Name>
        <Description>Adds new policies to the Antiquity Age</Description>
        <Authors>Firaxis</Authors>
        <AffectsSavedGames>1</AffectsSavedGames>
    </Properties>
    <ActionCriteria>
        <Criteria id="antiquity-age-current">
            <AgeInUse>AGE_ANTIQUITY</AgeInUse>
        </Criteria>
    </ActionCriteria>
    <ActionGroups>
        <ActionGroup id="antiquity-game" scope="game" criteria="antiquity-age-current">
            <Actions>
                <UpdateDatabase>
                    <Item>sql_statements/65a41eff-c3b5-4982-92d1-ee02ea02e9b8.sql</Item>
                </UpdateDatabase>
            </Actions>
        </ActionGroup>
    </ActionGroups>
</Mod>

Installation

With uv (preferred):

uv add pyciv7

Or with pip:

pip install pyciv7

Metadata

Release files for pyciv7 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyciv7 1.1.0
File Size Uploaded
pyciv7-1.1.0.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyciv7 1.1.0
File Interpreter ABI Platform
pyciv7-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / pyciv7-1.1.0.tar.gz

Download URL pyciv7-1.1.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b2cb9561af434fc68a50bd9510b09d157204aa99e58ba083fcc66cb35648bc5
BLAKE2b-256 checksum
How to use checksums
4572f1bba74233569d03190ee8f8216d0f082851e23498879b8f796f4c04dd7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.15

Release files / pyciv7-1.1.0-py3-none-any.whl

Download URL pyciv7-1.1.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc249f6f4137b57f6f2c8b80b3dd6b81c4318390c974f1e05ea9fd7b708e6134
BLAKE2b-256 checksum
How to use checksums
a48d952d69dd18ac53f8ee36fe27874c58d8565d7e576b5058bb1d211eb45ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.15

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page