This release is a pre-release and may not be stable for production use.
libscid
High-performance Python bindings for libscid, the standalone C++ chess game representation, PGN manipulation, and database library derived from Scid and ScidUp.
libscid provides modern, type-safe, and ergonomic Python abstractions for chess game representation, standard-compliant PGN parsing and serialization, functional move tree navigation, FIDE tournament rule adjudication, position analysis, and multi-criteria database search.
1. Key Features
- Immutable Cursor Navigation: Functional, side-effect-free move tree traversal with explicit mutation semantics for variations and comments.
- Event-Driven Movetext Streaming: Hierarchical generator stream (
iter_movetext) yielding structured events (MovetextLineStart,MovetextMove,MovetextLineEnd) for clean formatting and analysis. - FIDE Tournament Arbiter: Accurate adjudication of standard draw claims along any move sequence, including the Fifty-Move Rule and Threefold Repetition.
- High-Performance Database Engine: In-memory and persistent indexing for Scid databases and PGN archives, enabling rapid header searching, criteria filtering, and sorted index views without parsing full movetext.
- Type-Safe & Pythonic: Fully typed (PEP 561 compliant), modern Python API (>= 3.10) designed around the principle of Least Surprise.
2. Installation
Install the pre-compiled binary wheel from PyPI:
pip install libscid
Prebuilt wheels are available for Linux x86-64 with glibc 2.39 or newer, Apple Silicon on macOS 15 or newer, and Windows x64. Linux needs compatible glibc and C++ runtime libraries; Windows needs the Microsoft Visual C++ 2015–2022 Redistributable (x64). It's straightforward to build a wheel for other platforms too. See the installation guide for the full runtime requirements and steps to roll your own.
3. Quick Start
3.1. Parsing PGN and Navigating Moves
import libscid
# Parse a game from PGN string
pgn_data = """[Event "World Championship"]
[Site "Reykjavik ISL"]
[Date "1972.07.23"]
[Round "6"]
[White "Fischer, Robert J."]
[Black "Spassky, Boris V."]
[Result "1-0"]
1. c4 e6 2. Nf3 d5 3. d4 Nf6 4. Nc3 Be7 5. Bg5 O-O 6. e3 h6 7. Bh4 b6 1-0
"""
game = libscid.Game.from_pgn(pgn_data)
print(f"{game.get_tag('White')} vs {game.get_tag('Black')} ({game.get_tag('Result')})")
# Traverse moves sequentially using an immutable cursor
cursor = game.create_cursor()
while not cursor.is_line_end:
cursor = cursor.next()
print(f"Move: {cursor.previous_move_san:<6} FEN: {cursor.position.fen}")
3.2. Hierarchical Movetext & Variation Streaming
import libscid
game = libscid.Game.from_pgn("1. e4 e5 (1... c5 2. Nf3) 2. Nf3 Nc6 *")
for event in game.iter_movetext():
match event:
case libscid.MovetextLineStart(variation_depth=depth):
indent = " " * depth
print(f"{indent}[Start Variation (depth {depth})]")
case libscid.MovetextMove(san=san, comment=comment):
print(f"{indent}Move: {san}" + (f" ({comment})" if comment else ""))
case libscid.MovetextLineEnd():
print(f"{indent}[End Variation]")
3.3. FIDE Tournament Rule Adjudication
import libscid
# Position repeated 3 times in standard play
pgn = "1. Nf3 Nf6 2. Ng1 Ng8 3. Nf3 Nf6 4. Ng1 Ng8 *"
cursor = libscid.Game.from_pgn(pgn).create_cursor().to_game_end()
print("Threefold repetition:", cursor.arbiter.can_claim_threefold_repetition) # True
print("Fifty-move rule:", cursor.arbiter.can_claim_fifty_move_rule) # False
3.4. Database Indexing and Multi-Criteria Filtering
import libscid
# Open a PGN archive in read-only mode with instant header indexing
db = libscid.Database.open_pgn_read_only("games.pgn")
print(f"Total indexed games: {db.game_count}")
# Query using structured criteria
criteria = libscid.HeaderCriteria(
white="Kasparov",
result="1-0",
eco_min="B80",
eco_max="B89",
)
results = db.search.headers(criteria)
print(f"Matching games: {results.game_count}")
# Fetch top results sorted by date descending
for index in results.get_game_indices(sort_criteria="D-", start_row=0, row_count=5):
print(f"{db.get_tag(index, 'Date')}: {db.get_tag(index, 'White')} vs {db.get_tag(index, 'Black')}")
4. Documentation & Resources
- Full Documentation & Guides: https://libscid.bahmanm.com/python/
- API Reference: https://libscid.bahmanm.com/python/reference/
- C ABI Documentation: https://libscid.bahmanm.com/capi/
- Source Code & Issue Tracker: https://github.com/bahmanm/libscid
5. Licence
libscid is released under the GNU General Public License v2.0 (GPL-2.0-only). See the COPYING file for full licence details.
Metadata
Release files for libscid 1.0.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| libscid-1.0.0b1.tar.gz | 3.9 MB | Without provenance | Details for libscid-1.0.0b1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| libscid-1.0.0b1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for libscid-1.0.0b1-py3-none-win_amd64.whl |
| libscid-1.0.0b1-py3-none-manylinux_2_39_x86_64.whl | Python 3 | none | Linux glibc 2.39+ x86-64 | Details for libscid-1.0.0b1-py3-none-manylinux_2_39_x86_64.whl |
| libscid-1.0.0b1-py3-none-macosx_15_0_arm64.whl | Python 3 | none | macOS 15.0+ ARM64 | Details for libscid-1.0.0b1-py3-none-macosx_15_0_arm64.whl |
Total release size: 4.9 MB
Release files / libscid-1.0.0b1.tar.gz
| Download URL | libscid-1.0.0b1.tar.gz |
|---|---|
| Size | 3.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
922e828afc6afe6265a26b48b9486cf2e4b65bdcc574ac020ab2b539b52fc509
|
|
BLAKE2b-256 checksum How to use checksums |
d317e50e5d48a664f10f8e4f1f2633d06b7dfbd266c03f5a169c91c5b0afa80b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / libscid-1.0.0b1-py3-none-win_amd64.whl
| Download URL | libscid-1.0.0b1-py3-none-win_amd64.whl |
|---|---|
| Size | 307.1 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
eb5d590893a8ac1815f6ca938dc930d8a8bce8c18fc096b61165a13bafd34acd
|
|
BLAKE2b-256 checksum How to use checksums |
2785ef9453a361e3b3560ea0e522ce770a72a94737272fb4655caf074fa2c713
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / libscid-1.0.0b1-py3-none-manylinux_2_39_x86_64.whl
| Download URL | libscid-1.0.0b1-py3-none-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 362.8 kB |
| Tags | Linux glibc 2.39+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
cc08332f8f57136604740359f14b8a51dd55a08945640cfe74bec0a08efad3d4
|
|
BLAKE2b-256 checksum How to use checksums |
05f9550def1ecd905f04036c3bfc729b485a9665303a3a29248df61d3533bd57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / libscid-1.0.0b1-py3-none-macosx_15_0_arm64.whl
| Download URL | libscid-1.0.0b1-py3-none-macosx_15_0_arm64.whl |
|---|---|
| Size | 306.9 kB |
| Tags | Python 3 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fe245e76794774a4dfeafa6c0b4bed619b26900170ed52735573b3de22d00cf0
|
|
BLAKE2b-256 checksum How to use checksums |
89f36679ddc03cd27bab4ddcccc4cb2cb38817f34f80a55fa2b0ac74aab03f5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for libscid 1.0.0b1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.