Skip to main content

Literate package development with Jupyter

Project description

Literary logo with an orange cursive uppercase L inside black square brackets

Literary

pypi-badge binder-badge wiki-badge gitter-badge

TL;DR

Literary is a Python tool to make Jupyter (IPython) notebooks behave like pure-Python packages. This allows pure-Python packages to be generated from notebooks, and notebooks to be imported at runtime.

This package is an exploration of the literate programming idea pioneered by Donald Knuth and implemented in the nbdev package. Although nbdev looks to be a very mature and comprehensive tool, it resembles a significant departure from conventional package development. Literary is an exploration of what a smaller nbdev might look like.

Philosophy 📖

  1. Low mental overhead
    Realistically, most Python programmers that wish to write packages need to have some familiarity with the Python package development model, including the conventional structure of a package. For this reason, I feel that it is important to design literary such that these skills translate directly to designing libraries with notebooks
  2. Minimal downstream impact
    Users of literary packages should not realise that they are consuming notebook-generated code at runtime. This means that a pure-Python package needs to be generated from the notebooks, and it must use the conventional import model. For this reason, literary should only exist as a development dependency of the package.

Differences with nbdev

  • Use of cell tags instead of comments or magics to dictate exports
  • Use of nbconvert machinery to build the pure-Python lib package
  • Use of import hooks to import other notebooks
    • Maintains a similar programming model to conventional module development
    • Reduces the need to modify notebook contents during conversion
  • Minimal runtime overhead
    • Features like patch are removed from the generated module (& imported notebook source) using AST transformations
  • Currently no documentation generation
    • Loosely, the plan is to use existing notebook-book tooling to re-use the existing Jupyter ecosystem

Differences with Knuth

Knuth introduced the tangle and weave programs to produce separate documentation and source code for compilation. Literary differs in treating the notebook as the "ground truth" for documentation + testing, and generating smaller source code for packaging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

literary-1.8.2.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

literary-1.8.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file literary-1.8.2.tar.gz.

File metadata

  • Download URL: literary-1.8.2.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for literary-1.8.2.tar.gz
Algorithm Hash digest
SHA256 b88838802a2398a84aec37c1aa0fd28eec92e6ad787e1f2a1e07334619ca10c3
MD5 4bedac13942aed06d31e3de2b7251471
BLAKE2b-256 9b394846b0746f25105facac445f5554d12f25c8c964cc5ff6290062b262eb8f

See more details on using hashes here.

File details

Details for the file literary-1.8.2-py3-none-any.whl.

File metadata

  • Download URL: literary-1.8.2-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for literary-1.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9e8e73be633137df0f0d464a526a0b327cbde4079de7c5fa177194de6ed6c4
MD5 c0cc6cc7ad86038c7409ce76d3f23daa
BLAKE2b-256 17f47e6fac0236112a2559b2f04abb38b4d8d080d1361f44131b8ea88c493b4a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page