Skip to main content

Biblelib

Release Build status codecov Commit activity Docs Code style with black Imports with isort License

Utilities for working with Bible books, references, pericopes, and other units. Note this does not include any actual Bible texts.

Installation

$ pip install biblelib

Data

Most data ships inside the package (book metadata, versification vref files and scheme JSON), so the library works offline out of the box.

The two large Macula word-level mapping tables (used by biblelib.word.mappings and biblelib.word.fromubs) are the exception: they are downloaded on first use and cached locally, rather than bundled. They are verified against pinned SHA256 hashes.

  • The cache location follows the OS convention (e.g. ~/Library/Caches/biblelib on macOS, ~/.cache/biblelib on Linux). Set the BIBLELIB_DATA_DIR environment variable to relocate it.

  • To pre-populate the cache while online — for offline/air-gapped use, or to avoid concurrent downloads when running a parallel (pytest-xdist) test suite — run the bundled command:

    $ biblelib-download-data
    

Importing biblelib and biblelib.word never triggers a download; data is fetched only when a mapping is actually used.

Usage

Book metadata

from biblelib.book import Books

books = Books()
books["MRK"]           # <Book: MRK>
books["MRK"].name      # 'Mark'
books["MRK"].osisID    # 'Mark'
books.fromosis("Matt").name      # 'Matthew'
books.frombiblia("Mk").usfmname  # 'MRK'
books.findbook("Ge")             # <Book: GEN>  (searches all schemes)

Rendering Bible references

BCVID (book-chapter-verse) and BCVIDRange are the primary reference types. Several rendering methods are available:

from biblelib.word import BCVID, BCVIDRange

ref = BCVID("41004003")      # Mark 4:3
ref.to_usfm()                # 'MRK 4:3'
ref.to_nameref()             # 'Mark 4:3'    (full English name)
ref.to_abbrevref()           # 'Mk 4:3'      (biblia abbreviation)
ref.to_osisID()              # 'Mark 4:3'
ref.to_biblia()              # 'Mk 4:3'

rng = BCVIDRange(BCVID("41004003"), BCVID("41004008"))
rng.to_nameref()             # 'Mark 4:3-4:8'
rng.to_abbrevref()           # 'Mk 4:3-4:8'

Localized rendering

to_nameref() and to_abbrevref() accept an optional lang parameter using ISO 639-3 three-letter codes. The following languages are currently bundled:

Code Language Source translation
apd Sudanese Arabic Van Dyck Bible (OT); Biblica Sudanese Arabic NT
arb Arabic Van Dyck Bible (Smith-Van Dyck, 1865)
bis Bislama Baibel long Bislama (BSSP, 1995)
fra French Bible en français courant / Louis Segond
hau Hausa Littafi Mai Tsarki (Bible Society of Nigeria)
hin Hindi Bible Society of India Hindi Old Version (Re-edited)
ibo Igbo Akwụkwọ Nsọ (Bible Society of Nigeria)
ind Indonesian Terjemahan Baru (LAI, 1974/rev.)
nep Nepali Pavitra Grantha (Nepal Bible Society)
nld Dutch Herziene Statenvertaling (HSV, 2010)
por Portuguese Almeida Revista e Corrigida
rus Russian Synodal Translation (Синодальный перевод, 1876)
spa Spanish Reina-Valera / NVI
swh Swahili Swahili Union Version (Toleo la Umoja)
tpi Tok Pisin Baibel long Tok Pisin (BSPNG, 1989)
vie Vietnamese Kinh Thánh Tin Lành 1925
zhs Chinese (Simplified) Chinese Union Version Simplified (和合本简体)
zht Chinese (Traditional) Chinese Union Version Traditional (和合本)
zlm Malay Alkitab dalam Bahasa Malaysia (BSM/BSS)

Note: Non-English book names and abbreviations were AI-generated from the named source translations and should be verified by native-language speakers before production use, particularly for deuterocanonical and extended-canon entries.

from biblelib.word import BCVID, BCVIDRange

ref = BCVID("01001001")
ref.to_nameref(lang="fra")    # 'Genèse 1.1'
ref.to_abbrevref(lang="fra")  # 'Gn 1.1'
ref.to_nameref(lang="nld")    # 'Genesis 1:1'
ref.to_abbrevref(lang="hau")  # 'Far 1:1'
ref.to_nameref(lang="vie")    # 'Sáng Thế Ký 1:1'
ref.to_abbrevref(lang="vie")  # 'St 1:1'

rng = BCVIDRange(BCVID("41004003"), BCVID("41004008"))
rng.to_nameref(lang="fra")    # 'Marc 4.3-4.8'
rng.to_abbrevref(lang="fra")  # 'Mc 4.3-4.8'

Note that the chapter-verse separator is language-specific (English and most languages use :, French uses .).

You can also work with LocalizedBooks directly:

from biblelib.book import get_localized_books

fra = get_localized_books("fra")
fra.get_name("GEN")    # 'Genèse'
fra.get_abbrev("GEN")  # 'Gn'
fra.cv_sep             # '.'

Adding a language

Create biblelib/book/books_<lang>.tsv (e.g. books_spa.tsv for Spanish) with three tab-separated columns and optional metadata comments:

# cv_sep: .
usfmname	name	abbrev
GEN	Génesis	Gn
EXO	Éxodo	Éx
...

Supported metadata comments:

Key Description Default
cv_sep Chapter-verse separator character :

No code changes are required. The new language is available immediately via lang="spa" (or whatever code you used).

Acknowledgements

Metadata

Release files for biblelib 0.6.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 biblelib 0.6.0
File Size Uploaded Provenance Actions
biblelib-0.6.0.tar.gz 545.5 kB Without provenance Details for biblelib-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / biblelib-0.6.0.tar.gz

Download URL biblelib-0.6.0.tar.gz
Size 545.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ef76b39e64faaaa8fc3995e68ce574b9760a24abb519e158668861320a9328db
BLAKE2b-256 checksum
How to use checksums
70abc4830710d775e97a544fd1adbd964938f0cb49ecb5ccec16d49abdda4def
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.7 Darwin/25.5.0

Release files / biblelib-0.6.0-py3-none-any.whl

Download URL biblelib-0.6.0-py3-none-any.whl
Size 561.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbd1d4a7197fe896c757f970dc4497dd3fb26da18400d2fbd35678d9be12868a
BLAKE2b-256 checksum
How to use checksums
3ef8ec00b6ed163f3c27eb496679bd0bdfed158e76569703f08dfdb494a05109
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.7 Darwin/25.5.0

Security for biblelib 0.6.0

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.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files No provenance

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