Skip to main content

Build Status Coverage Status license

mkepub

mkepub is a minimalistic library for creating .epub files.

Pros:

  • Easy to use, minimalistic API.
  • Automatically generated TOC.
  • Support for nested TOC of any depth.
  • Support for embedded images.
  • Support for embedded fonts.
  • In-progress books are stored on disk rather than in memory, enabling creation of large (5000+ pages, 20+ MiBs) epub files.
  • Adherence to the EPUB3 specs.
  • Support for most of the EPUB metadata, including language, subject, description, and rights.

Cons:

  • No support for custom page filenames or directory structure.
  • No support for reading or editing epub files.
  • No content validation - using broken or unsupported html code as page content will lead to mkepub successfully creating a .epub file that does not meet EPUB3 specifications.
  • Probably other issues.

Basic Usage

import mkepub

book = mkepub.Book(title='An Example')
book.add_page(title='First Page', content='Lorem Ipsum etcetera.')
book.save('example.epub')

Advanced Usage

import mkepub

book = mkepub.Book(title='Advanced Example', author='The Author')
# multiple authors can be specified as a list:
# mkepub.Book(title='Advanced Example', authors=['The First Author', 'The Second Author'])
book.set_cover_from_file('cover.jpg')
book.set_stylesheet_from_file('style.css')

first = book.add_page('Chapter 1', 'And so the book begins.')

child = book.add_page('Chapter 1.1', 'Nested TOC is supported.', parent=first)
book.add_page('Chapter 1.1.1', 'Infinite nesting levels', parent=child)
book.add_page('Chapter 1.2', 'In any order you wish.', parent=first)

book.add_page('Chapter 2', 'Use <b>html</b> to make your text <span class="pink">prettier</span>')

book.add_page('Chapter 3: Images', '<img src="images/chapter3.png" alt="You can use images as well">')
# as long as you add them to the book:
with open('chapter3.png', 'rb') as file:
    book.add_image('chapter3.png', file.read())

# you can also add custom fonts to the book
book.add_font_from_file('your_font.woff')

book.save('advanced.epub')

Metadata

Release files for mkepub 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkepub 1.2.2
File Size Uploaded
mkepub-1.2.2.tar.gz 8.6 kB Details

Built distribution (wheel)

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

Total release size: 17.4 kB

Release files / mkepub-1.2.2.tar.gz

Download URL mkepub-1.2.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a8a38cccb6100f452074b2bf6789e3cbd3e3fe41173764df74ae4c5fd79c574e
BLAKE2b-256 checksum
How to use checksums
54e7660a77ce993719d8afd9adda862aa467770b90061c9c6b37ecf50fcc7266
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mkepub-1.2.2-py3-none-any.whl

Download URL mkepub-1.2.2-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ccdf41f614fdb2a709b3a4aa664edb6d795438896a21bfaabfbdf7b773b9b4f
BLAKE2b-256 checksum
How to use checksums
7d82a8ed5e82dbbd687b9689b1785d52e877a06a6ea87831858e1c2ff9b8d469
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2

1 release file

1.1

2 release files

1.0

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