Overview

When creating Python packages, I use nbdev.

https://nbdev.fast.ai/

nbdev is described as follows:

Write, test, document, and distribute software packages and technical articles — all in one place, your notebook.

This article serves as a memo when using nbdev.

Installation

The following tutorial page is a helpful reference.

https://nbdev.fast.ai/tutorials/tutorial.html

Below is a brief overview of the workflow.

After installing the related tools, create a GitHub repository, clone it, and then execute the following in the cloned directory.

nbdev_new

After that, also run the following.

nbdev_install_hooks

Then edit files like 00_core.ipynb in the nbs folder, and execute the following in the last cell of the notebook.

importnbdev;nbdev.nbdev_export()

As a result, Python modules are automatically created.

Installing the Package

Within the Same Folder

Execute the following.

pipinstall-e.[dev]'

From a Different Folder

As one example, install by specifying the absolute path.

Example: For /Users/hogehoge/tei_xml_tools

pipinstall-e/Users/hogehoge/tei_xml_tools

By using the -e option, changes made to the package during development can be used immediately.

Using the Library

By using % as shown below, changes made during development could be reflected.

#%%frar%euolltmoooaartddee__lieeo_xxaxttdmlaa2_uutttoooorrleesll.oocaaoddreimport

Summary

Additionally, commands are provided for previewing documentation and uploading to PyPI. If the opportunity arises, I would like to write an article about using nbdev in general.