Skip to main content

🏗️ simplibs-guide

PyPI Python Licence tests

One command makes the files of a new library, and one command lists what is not ready for the upload.

simplibs-guide is the ground of the simplibs system, level 00. It holds the guides that say how a library of the system is made, and the tools that apply them: a generator that makes the files of a new library from the templates, a check that compares a folder with those templates and with the facts of the checklist, and small helpers for handing files over (a zip, a batch of files written as one text, and a folder packed into a batch). The guides, the templates and the tools read the same MANIFEST.toml, so what a guide says is what the generator makes and what the check looks for. No other library imports it: it is used at the command line, and the functions behind the commands are there for scripts.

simplibs-guide new simplibs-text     # the files of a new library, made from the templates
simplibs-guide check simplibs-text   # what is not ready for the upload, and where
from pathlib import Path
from simplibs.guide import check_library

findings = check_library(Path("simplibs-text"))
findings[0]["id"]                    # -> 'todo-left:CHANGELOG.md'

simplibs-guide stands before simplibs-exception and has no dependency, so its one error, GuideError, is a plain error with the same shape of message and not a card of that library.


🧭 The Core Philosophy

A guide for building libraries usually lives in a wiki or in the history of a chat, and a template lives in a copy of the last library. Both drift: the guide says one thing, the last library did another, and nobody knows which is right until the upload fails. simplibs-guide takes those traps seriously:

  • One source for the guide, the generator and the check. MANIFEST.toml lists every file of the skeleton. The generator makes them, the check compares them, and the guide describes them, so none of the three can drift away from the others unnoticed.
  • A tool that only looks, changes nothing. check reads and reports. new and zip say what they would do with --dry-run, and new skips a file that exists unless --force is given.
  • Nothing is written before everything is valid. A batch with one wrong path writes no file, and a plan that clashes with the disk writes none.
  • An exception is a rule with a reason. What the author leaves out of the checks is written in pyproject.toml with its reason, and a rule that matches no file is itself a finding.
  • Every failure advises. A GuideError says what happened, which value failed, what was expected and what to do next.
  • Everything is also a function. Each command is a function of the root. The command prints the result and turns an error into the exit code 1.
  • Layers that only look left. exceptions ← derive_library_names, load_manifest, archive_library ← pack_and_unpack_batches ← scaffold_library ← check_library ← cli — every layer imports only from those before it.
from simplibs.guide import plan_batch

plan_batch("# >>> ../outside.txt\nx\n")   # -> raises: GUIDE_BATCH_PATH_INVALID_ERROR, the path leaves the folder

📦 Installation

pip install simplibs-guide

Requires Python 3.11+. The library has no runtime dependency. It installs the command simplibs-guide, which python -m simplibs.guide starts as well.


🚀 Quick Start in 60 Seconds

Level 1: Make a new library

The command and the function do the same; use one of them, because the second run skips every file that exists.

simplibs-guide new simplibs-text          # asks once; --yes does not, --dry-run only lists
from pathlib import Path
from simplibs.guide import scaffold_library

report = scaffold_library(Path("simplibs-text"))   # the name of the folder is the name of the library
"README.md" in report["created"]                   # -> True
report["skipped"]                                  # -> []   (a file that exists is skipped, unless force=True)

Level 2: List what is not ready

simplibs-guide check simplibs-text        # nothing is changed; exit code 1 when something is found
from pathlib import Path
from simplibs.guide import check_library

findings = check_library(Path("simplibs-text"))
sorted({finding["check"] for finding in findings})   # -> ['comment-left', 'placeholder-left', 'todo-left']
findings[0]["id"]                                    # -> 'todo-left:CHANGELOG.md'

Level 3: Hand files over

simplibs-guide zip simplibs-text               # the zip without what git leaves out
simplibs-guide create-batch simplibs-text      # simplibs-text_batch.txt: the whole folder as one text
simplibs-guide create-bare-batch simplibs-text # only the Python code, without comments, to be read
from pathlib import Path
from simplibs.guide import archive_folder, plan_batch, write_batch

report = archive_folder(Path("simplibs-text"), dry_run=True)   # the zip without what git leaves out
report["written"], ".gitignore" in report["files"]             # -> (False, True)

plan = plan_batch("# >>> notes/a.txt\nhello\n# >>> b.txt\nworld\n")   # one text, two files
plan                                                          # -> {'notes/a.txt': 'hello', 'b.txt': 'world'}
write_batch(Path("out"), plan, dry_run=True)["files"]          # -> ['notes/a.txt', 'b.txt']

The other way round, a folder becomes one batch, whole or only its Python code:

from pathlib import Path
from simplibs.guide import create_batch, create_bare_batch

report = create_batch(Path("simplibs-text"), dry_run=True)       # the whole folder as one text
len(report["files"]), report["skipped"]                          # -> (11, {})
create_bare_batch(Path("simplibs-text"), dry_run=True)["files"]   # -> ['src/simplibs/text/__init__.py', 'tests/test_architecture.py', 'tests/test_public_api.py']

Level 4: Names and safety

from simplibs.guide import GuideError, derive_name_tokens, plan_batch

derive_name_tokens("simplibs-text-case")   # -> {'NAME': 'text-case', 'IMPORT': 'text_case', 'UPPER': 'TEXT_CASE'}

try:
    plan_batch("no marker line, so no file")
except GuideError as error:
    error.error_name                       # -> 'GUIDE_BATCH_EMPTY_ERROR'

🛠️ Architecture & Package Structure

src/simplibs/guide/
├── __init__.py                    ◄── the functions and the types of the tools
├── __main__.py                    ◄── python -m simplibs.guide
├── cli/                           ◄── the command line: new, check, zip, create-files, create-batch, create-bare-batch
├── exceptions/                    ◄── GuideError, the one error
├── logic/                         ◄── what the tools do; each folder is named by what it does
│   ├── archive_library/           ◄── pack a folder into a zip
│   ├── check_library/             ◄── list what is not ready for the upload
│   ├── derive_library_names/      ◄── the shapes of the name of a library
│   ├── load_manifest/             ◄── read MANIFEST.toml (internal)
│   ├── pack_and_unpack_batches/   ◄── make the files of a batch, and pack a folder into one
│   └── scaffold_library/          ◄── make the files of a new library
└── templates/                     ◄── MANIFEST.toml, the templates and the scripts (data)

The root exports the functions and the types that appear in their signatures. The command line is started by the command, not imported, and the manifest is the file of the tools themselves, so neither is exported:

from simplibs.guide import check_library, scaffold_library, GuideError   # functions and the error
from simplibs.guide import Finding, ScaffoldReport                        # types of the answers

🖥️ cli/ — The command simplibs-guide

One command with six subcommands. Each prints what it did, asks before it writes when a whole library is made, and ends with the exit code 0, or 1 for an error, for a finding of check and for a closed pipe.

Command Description / Parameters
new Makes the files of a new library; the name of the folder is the name of the library (folder, --yes, --dry-run, --force).
check Lists what is not ready for the upload; nothing is changed (folder).
zip Packs a folder into a zip without what git leaves out (folder, --output, --dry-run).
create-files Makes the files of a batch; the batch is always named (batch, --folder, --only, --dry-run).
create-batch Packs the text files of a folder into one batch (folder, --output, --max-depth, --dry-run).
create-bare-batch Packs only the Python code of a folder into one batch, without comments, docstrings and design notes, to be read (folder, --output, --max-depth, --dry-run).

➡️ README_GUIDE_CLI


🔧 logic/ — What the tools do

Each tool has a folder of its own, and each folder has a section below. A function plans first and writes second, so that a mistake is found before a file is touched.

Folder What it does
scaffold_library/ Makes the files of a new library from the templates.
check_library/ Lists what is not ready for the upload.
archive_library/ Packs a folder into a zip.
pack_and_unpack_batches/ Makes the files of a batch, and packs a folder into one.
derive_library_names/ Turns the name of a library folder into the shapes of its name.
load_manifest/ Reads MANIFEST.toml, the list of the files of the skeleton; internal, not exported.

-------------|---------------------------------------------------------------------------------------| | scaffold/ | Makes the files of a new library from the templates. | | check/ | Lists what is not ready for the upload. | | archive/ | Packs a folder into a zip. | | batch/ | Makes the files of a batch, and packs a folder into one. | | names/ | Turns the name of a library folder into the shapes of its name. | | manifest/ | Reads MANIFEST.toml, the list of the files of the skeleton; internal, not exported. |


🏭 logic/scaffold_library/ — Make a new library

The name of the folder is the name of the library (simplibs- and its name), and the files are made from the templates that MANIFEST.toml lists. A file that exists is skipped, unless force is given.

Function Description / Parameters
plan_scaffold Builds the plan of a new library: its folders and the content of its files (folder_name, year, templates_root=None).
scaffold_library Makes the files of a new library in a folder (folder, keyword-only: force=False, dry_run=False, year=None, templates_root=None).
write_scaffold Writes a plan into a folder (root, plan, keyword-only: force=False, dry_run=False).
Type Description
ScaffoldPlan The folders and the content of the files that are going to be made.
ScaffoldReport The folders and the files that were created, overwritten or skipped.

➡️ README_GUIDE_SCAFFOLD_LIBRARY


🔍 logic/check_library/ — List what is not ready

Eleven checks run on a folder: the files of the skeleton that are missing or changed, a token, a TODO marker, a comment or a placeholder that was left in a file, facts that two files say differently (the version, the Python, the year of the licence), and a Markdown link that leads nowhere. The author leaves a file out of a check with a rule and a reason in pyproject.toml; a rule that matches no file is a finding too.

Function Description / Parameters
check_library Runs every check on the folder of a library (folder, keyword-only: templates_root=None).
Type Description
Finding One thing that is not ready: its id, its check, its path and a message.

➡️ README_GUIDE_CHECK_LIBRARY


🗜️ logic/archive_library/ — Pack a folder

The zip holds what git would keep: the folders that are not part of the repository (.git, .venv, the caches) and the working files are left out. The paths in the zip start in the folder itself.

Function Description / Parameters
archive_folder Packs a folder into a zip, or only lists what would be packed (folder, keyword-only: output=None, dry_run=False).
Type Description
ArchiveReport The folder, the zip, the files, whether it was written and its size in KB.

➡️ README_GUIDE_ARCHIVE_LIBRARY


🗂️ logic/pack_and_unpack_batches/ — Make the files of a batch

A batch is one text in which every file starts with a line # >>> relative/path. Every path is checked before the first file is written, so one wrong path stops everything. The other way round, a folder is packed into a batch, whole or only its Python code; what is left out is named with its reason.

Function Description / Parameters
plan_batch Cuts a batch into the files it holds (text, keyword-only: allowed_roots=()).
write_batch Writes the files of a plan into a folder (root, plan, keyword-only: dry_run=False).
create_files Reads a batch file and makes its files in a folder (folder, batch, keyword-only: dry_run=False, allowed_roots=()).
create_batch Packs the text files of a folder into one batch, or only lists them (folder, keyword-only: output=None, dry_run=False, max_depth=None).
create_bare_batch Packs only the Python code of a folder into one batch, without comments, docstrings and design notes, to be read (folder, keyword-only: output=None, dry_run=False, max_depth=None).
Type Description
BatchReport The folder, the files, which of them were overwritten, and whether they were written.
BatchBuildReport The folder, the batch, the packed files, the files that were left out with the reason, whether it was written and its size in KB.

➡️ README_GUIDE_PACK_AND_UNPACK_BATCHES


🔤 logic/derive_library_names/ — The shapes of a name

One name has three shapes: the name of the folder (simplibs-text-case), the name that stands after the prefix (text-case) and the name of the import (text_case).

Function Description / Parameters
derive_name_tokens Turns the name of a library folder into the three shapes of its name (folder_name).

➡️ README_GUIDE_DERIVE_LIBRARY_NAMES


📚 The Guides

The texts of the guides are the other half of the library. They are in the repository, in docs/, and they are not part of the package.

Guide What it answers
Index where to start, the levels of the libraries, and how a library is made in three threads
Code how the code of a library is written: files, imports, functions, classes, errors
Tests what the tests of a library hold and when they are done
README how the main README and the helper READMEs are written
Structure which files a library has, how they are named and filled in
Release how a library gets to GitHub and PyPI
Workflow how files are handed over and changed
Sets three ready zips of the guide, one for each thread of a library: code, tests and documentation

🌍 Pipes, Windows and Line Endings

  • A closed pipe is not a crash. simplibs-guide check | head ends with the exit code 1 and without a traceback.
  • Paths are written with /. The scripts that new leaves in __DOC__/_tools/ print them so on Windows too.
  • The repository is kept on LF. new makes .gitattributes for it. A folder that already holds files with CRLF needs git add --renormalize . once, after the file is there, in a commit of its own; _fix_line_endings.py in __DOC__/_tools/ turns the CRLF of the files on the disk into LF.

⚠️ Exceptions

The library defines one error, GuideError, and no other. It carries the parts of the failure (error_name, what, value, expected, how_to_fix) and the commands print its text as it is. The name of an error is GUIDE_, the folder it comes from, what happened, and _ERROR; a test compares the name and not the sentence.

Error name Raised by Raised when
GUIDE_ARCHIVE_FOLDER_MISSING_ERROR archive_folder The folder to pack does not exist or is not a folder
GUIDE_ARCHIVE_OUTPUT_IS_FOLDER_ERROR archive_folder The path of the zip to write is a folder
GUIDE_BATCH_MISSING_ERROR create_files The batch file does not exist
GUIDE_BATCH_UNREADABLE_ERROR create_files The batch file cannot be read, or is not UTF-8
GUIDE_BATCH_EMPTY_ERROR plan_batch The text has no marker line, so it holds no file
GUIDE_BATCH_PATH_INVALID_ERROR plan_batch, write_batch A path cannot be used: it leaves the folder, names no file, or clashes with the disk
GUIDE_BATCH_ROOT_NOT_ALLOWED_ERROR plan_batch A path does not start in an allowed folder
GUIDE_BATCH_DUPLICATE_PATH_ERROR plan_batch One path is listed twice
GUIDE_BATCH_WRITE_FAILED_ERROR write_batch, create_batch, create_bare_batch The disk does not let the files or the batch be written
GUIDE_BATCH_FOLDER_MISSING_ERROR create_batch, create_bare_batch The folder to pack does not exist or is not a folder
GUIDE_BATCH_OUTPUT_IS_FOLDER_ERROR create_batch, create_bare_batch The path of the batch to write is a folder
GUIDE_BATCH_MAX_DEPTH_INVALID_ERROR create_batch, create_bare_batch The depth is below zero
GUIDE_BATCH_NOTHING_TO_PACK_ERROR create_batch, create_bare_batch No file is left to pack (a real run; a preview lists what was left out)
GUIDE_CHECK_FOLDER_MISSING_ERROR check_library The folder to check does not exist or is not a folder
GUIDE_CHECK_IGNORE_INVALID_ERROR check_library The rules of [tool.simplibs-guide.check] in pyproject.toml are not valid
GUIDE_MANIFEST_MISSING_ERROR load_manifest MANIFEST.toml of the templates does not exist
GUIDE_MANIFEST_UNREADABLE_ERROR load_manifest MANIFEST.toml cannot be read: it is not UTF-8 or not valid TOML
GUIDE_MANIFEST_ENTRY_ERROR load_manifest MANIFEST.toml breaks a rule; the message names the entry and the rule
GUIDE_MANIFEST_TEMPLATE_MISSING_ERROR load_manifest A template that MANIFEST.toml lists is not in the package
GUIDE_NAMES_MISSING_PREFIX_ERROR derive_name_tokens The value is not a text, or does not start with simplibs-
GUIDE_NAMES_INVALID_NAME_ERROR derive_name_tokens The part after the prefix is empty or breaks the rules of the name
GUIDE_NAMES_KEYWORD_NAME_ERROR derive_name_tokens The import name is a Python keyword
GUIDE_SCAFFOLD_UNKNOWN_TOKEN_ERROR plan_scaffold A template or a target uses a token that is not on the list
GUIDE_SCAFFOLD_ABOUT_MISSING_ERROR plan_scaffold The template of the token ABOUT does not exist
GUIDE_SCAFFOLD_TARGET_CONFLICT_ERROR write_scaffold A path of the plan clashes with something on the disk
GUIDE_SCAFFOLD_WRITE_FAILED_ERROR write_scaffold The disk does not let the library be written

➡️ README_GUIDE_EXCEPTIONS


  • simplibs-exception — the error cards of the system. GuideError has the same parts but stands before it, so it does not import it.

☯️ About simplibs

All libraries in the simplibs (Simple Libraries) ecosystem share a common engineering philosophy:

  • Dyslexia-friendly: We actively minimize cognitive load. Code is atomized into small, self-contained units, files are named directly after the logical task they perform, and explanations describe why something is designed, not just what it is.
  • Programmer's Zen: Nothing should be missing, and nothing should be superfluous. We value clean execution paths and robust, understandable code architectures over rushed, messy feature sets.
  • Defensive Style: We actively anticipate edge cases and failure modes so that only safe operational paths remain. Our code is built to degrade gracefully rather than crash unexpectedly.
  • Minimalism: Find the most direct path to the goal in as few operational steps as possible without taking shortcuts on safety, readability, or completeness.
  • Code as Craft: Code should be pleasant to look at, readable at a glance, and evoke structural harmony. We treat software engineering as a precision trade.

🤝 Contributing & Community

This is an open-source project built with love and care. We strongly believe in community collaboration and welcome any feedback, bug reports, or feature ideas!

  • Want to contribute? Feel free to open an Issue or submit a Pull Request.
  • Want to get in touch? If you'd like to discuss the project further, collaborate, or just say hello, feel free to open a GitHub Issue or start a Discussion.

📝 License

This library is released under the MIT License. Build great things!


Metadata

Release files for simplibs-guide 0.1.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 simplibs-guide 0.1.0
File Size Uploaded Provenance Actions
simplibs_guide-0.1.0.tar.gz 130.2 kB Without provenance Details for simplibs_guide-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simplibs-guide 0.1.0
File Interpreter ABI Platform Actions
simplibs_guide-0.1.0-py3-none-any.whl Python 3 none any Details for simplibs_guide-0.1.0-py3-none-any.whl

Total release size: 356.6 kB

Release files / simplibs_guide-0.1.0.tar.gz

Download URL simplibs_guide-0.1.0.tar.gz
Size 130.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6a39dafcde8f239d1a2be3210f277887ca39aed2e479653c32e66715c223ae34
BLAKE2b-256 checksum
How to use checksums
6856f801625637749a9e0a3a36748dcba101d57394811879fb530354d4b332b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / simplibs_guide-0.1.0-py3-none-any.whl

Download URL simplibs_guide-0.1.0-py3-none-any.whl
Size 226.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2177bebe4bbdca68d76365b19c6f7a1f403cc1cfc64a6d1737772cdddf5515b
BLAKE2b-256 checksum
How to use checksums
52bc9180e4eaef8cfab9a2e9ea64a362e46323cf2b0fb726a1e58d5dbd19737d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for simplibs-guide 0.1.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.1.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