Skip to main content

pgntools

PyPI Python versions License: MIT

Standalone PGN utilities for chess, built on python-chess and Stockfish. Tools chain together: build a repertoire from many games, evaluate it, weigh the branches for a trainer, and trace tree lines back to their source games.

Install

pip install pgntools

That gives you a pgntools command with one subcommand per tool, plus a short command per tool:

pgntools --help              # lists every tool
pgntools findseq --help      # a tool's own arguments
pgn-findseq --help           # the same tool, short form

python -m pgntools.<tool> works as well and always has — the three routes run the same code.

Stockfish is not installed by pip. annotate and playchance need the binary on the machine; the other four tools never touch an engine. Install it from your package manager or from stockfishchess.org, then point the tools at it:

pgntools annotate -f repertoire.pgn --engine /path/to/stockfish   # explicit, per run
export STOCKFISH_PATH=/path/to/stockfish                          # or for the whole shell

With neither given, the tools look for a stockfish on your $PATH.

Tools

Tool What it does
repertoire Merges all games of a .pgn/.zip into one variations tree (trimmed --tail plies past each line's last branch), optionally pruning moves played in fewer than --min-games games, with optional per-move game counts (--counts) and percentages (--prc).
annotate Adds a Stockfish [%eval] to every move of a variations tree, marks the engine's best move ! (adding it as a variation if missing) and every other move with its loss and ?!/?/??. Resumable — stop with Ctrl-C, rerun to continue.
playchance Weighs each choice at every junction of a variations PGN with a lichess-tools play chance prc:N (sums to 100), from one MultiPV search per junction. Rerunning with other --spread/--min-prc/--max-loss re-weighs without searching again.
glyphs Engine-free NAG annotator for an eval'd PGN (e.g. a game-anal analysis export): ??/?/?! by loss thresholds, missed mates, plus !, only-move □ and sacrifice !!/!? glyphs.
gamequery Given a move line of a merged repertoire tree, finds the original games that played it.
findseq Searches a multigame .pgn/.zip for the games whose mainline contains a SAN move sequence, at any ply.

Usage

pgntools repertoire -f capablanca_all.pgn -t 2 --counts --min-games 10 -o capablanca.repertoire.pgn
pgntools annotate   -f capablanca.repertoire.pgn -d 25 -s 60
pgntools playchance -f capablanca.repertoire.pgn -d 25 -s 60 --side black
pgntools glyphs     -f game.analysed.full.pgn
pgntools gamequery  -f capablanca_all.pgn -t capablanca.repertoire.pgn -l "e4 e5 Nf3"
pgntools findseq    -f capablanca_all.pgn -q "Be2 Bd7; Be3 e6"

Every tool takes its input with -f/--pgnfile and writes an output path derived from the input unless -o/--output says otherwise. Full argument tables and implementation notes live in .claude/rules/pgntools-<tool>.md in the repository.

Working on pgntools

git clone https://github.com/pgntools/pgntools.git
cd pgntools
python -m venv venv && venv/bin/pip install -r requirements.txt
venv/bin/python -m unittest discover -s tests -t .           # the full suite
venv/bin/python -m pgntools.repertoire -f pgns/capablanca_all.pgn   # a tool, uninstalled

Engine-dependent tests skip themselves when no Stockfish binary is found. pip install -e . additionally puts the pgntools and pgn-<tool> commands on your PATH from the checkout.

License

MIT — see LICENSE.

Metadata

Release files for pgntools 0.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 pgntools 0.1.0
File Size Uploaded
pgntools-0.1.0.tar.gz 52.8 kB Details

Built distribution (wheel)

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

Total release size: 86.9 kB

Release files / pgntools-0.1.0.tar.gz

Download URL pgntools-0.1.0.tar.gz
Size 52.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2fc3b3a2bca14760ded225331f9ac7e392f71996f7c3bac4087e545782d19aea
BLAKE2b-256 checksum
How to use checksums
cf24bae7fd247eed3844640c15a944d04156073bc069b2d1f983edfad749abed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / pgntools-0.1.0-py3-none-any.whl

Download URL pgntools-0.1.0-py3-none-any.whl
Size 34.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1607e533789043bb713a3526b2586031283819b56c3d56fcae0705dee0c23d14
BLAKE2b-256 checksum
How to use checksums
cbcf862138252579150b5f77326b79d0360c0d83d199875e25f2587100157b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

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