Skip to main content

Python bindings for the Sid Meier's Civilization VII Software Development Kit (SDK)

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyciv7-1.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyciv7-1.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file pyciv7-1.1.0.tar.gz.

File metadata

  • Download URL: pyciv7-1.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.15

File hashes

Hashes for pyciv7-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7b2cb9561af434fc68a50bd9510b09d157204aa99e58ba083fcc66cb35648bc5
MD5 a11447dda86ce446a21e3151116f05b3
BLAKE2b-256 4572f1bba74233569d03190ee8f8216d0f082851e23498879b8f796f4c04dd7a

See more details on using hashes here.

File details

Details for the file pyciv7-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyciv7-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.15

File hashes

Hashes for pyciv7-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc249f6f4137b57f6f2c8b80b3dd6b81c4318390c974f1e05ea9fd7b708e6134
MD5 f2eacf3194a1f14fea3e243c6bee4695
BLAKE2b-256 a48d952d69dd18ac53f8ee36fe27874c58d8565d7e576b5058bb1d211eb45ee1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page