Python bindings for the Sid Meier's Civilization VII Software Development Kit (SDK)
Project description
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
.modinfoXML 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b2cb9561af434fc68a50bd9510b09d157204aa99e58ba083fcc66cb35648bc5
|
|
| MD5 |
a11447dda86ce446a21e3151116f05b3
|
|
| BLAKE2b-256 |
4572f1bba74233569d03190ee8f8216d0f082851e23498879b8f796f4c04dd7a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc249f6f4137b57f6f2c8b80b3dd6b81c4318390c974f1e05ea9fd7b708e6134
|
|
| MD5 |
f2eacf3194a1f14fea3e243c6bee4695
|
|
| BLAKE2b-256 |
a48d952d69dd18ac53f8ee36fe27874c58d8565d7e576b5058bb1d211eb45ee1
|