β¨ Welcome to Stouputils Documentation β¨#
Versions: latest, v26.4.0, v26.3.4, v26.3.3, v26.3.2, v26.3.1, v26.3.0, v26.2.0, v26.1.1, v26.0.3, v1.31.0, v1.30.1, v1.29.6, v1.28.1, v1.27.1, v1.26.4, v1.25.0, v1.24.13, v1.23.2, v1.22.3, v1.21.4, v1.20.4, v1.19.5, v1.18.6, v1.17.0, v1.16.3, v1.15.1, v1.14.3
π οΈ stouputils#
Every utility you rewrite in each project, already written: colored logging, decorators, parallel maps, archives, backups, a CLI, and more.
Installation | Quick start | Modules | CLI | Documentation
π What is it?#
One import gives you the utilities every project ends up rewriting.
Logs are colored and timestamped, repeated lines collapse into (x3), decorators time and retry your functions, and multiprocessing gets a progress bar for free, and many more.
Everything is strongly typed, doctested on Python 3.12 to 3.15 including the free threaded builds, and every submodule is declared lazy (PEP 810) so import stouputils costs almost nothing on Python 3.15.
π§ Installation#
pip install stouputils
β¨ Enable tab completion on Linux (optional)
For a better CLI experience, enable bash tab completion:
# Option 1: Using argcomplete's global activation
activate-global-python-argcomplete --user
# Option 2: Manual setup for bash
register-python-argcomplete stouputils >> ~/.bashrc
source ~/.bashrc
After enabling completion, you can use <TAB> to autocomplete commands:
stouputils <TAB> # Shows: --version, -v, all_doctests, backup
stouputils all_<TAB> # Completes to: all_doctests
Note: Tab completion works best in bash, zsh, Git Bash, or WSL on Windows.
π Quick start#
import stouputils as stp
@stp.measure_time()
@stp.handle_error(message="Doubling failed")
def double(value: int) -> int:
return value * 2
stp.info("Starting", 3, "jobs")
stp.info("Starting", 3, "jobs") # A repeated line collapses instead of scrolling away
results: list[int] = stp.multithreading(double, [1, 2, 3], desc="Doubling")
stp.whatisit(results)
stp.warning("Two files were skipped")
[INFO 11:32:19] (x2) Starting 3 jobs
[PROGRESS 11:32:19] Execution time of double(): 0.003ms (2904ns)
[PROGRESS 11:32:19] Execution time of double(): 0.001ms (1031ns)
[PROGRESS 11:32:19] Execution time of double(): 0.003ms (2613ns)
Doubling: 100%|ββββββββββ| 3/3 [19358.33it/s, 00:00<00:00]
[What is it? 11:32:19] <class 'list'>, <id 127047922343936>: (length: 3, min: 2, max: 6) [2, 4, 6]
[WARNING 11:32:19] Two files were skipped
Colors, timestamps and the progress bar come from the defaults, they are configurable.
Send the same logs to a file with with stp.LogToFile("run.log"):, silence a noisy library with with stp.Muffle():, and swap multithreading for multiprocessing when the work is CPU bound.
π» From the command line#
The same toolbox is available as a CLI, one example per subcommand:
# Show version information of polars with dependency tree of depth 3
stouputils --version polars -t 3
# Run all doctests in a directory with pattern filter (fnmatch)
stouputils all_doctests "./src" "*_test"
# Repair a corrupted/obstructed zip archive
stouputils archive repair "./input.zip" "./output.zip"
# Create a delta backup
stouputils backup delta "./source" "./backups"
# Build and publish to PyPI (with minor version bump and no stubs)
stouputils build minor --no_stubs
# Generate changelog from git history (since a specific date, with commit URLs from origin remote, output to file)
stouputils changelog date "2026-01-01" -r origin -o "CHANGELOG.md"
# Redirect (move) a folder and create a junction/symlink at the original location
stouputils redirect "C:/Games/MyGame" "D:/Games/" --hardlink
π See the Extensive CLI Documentation section below for detailed usage and all available options.
π§° Modules#
Every name below links to its reference page.
stouputils/ βββ print # π¨οΈ Utility functions for printing (info, debug, warning, error, whatisit, breakpoint, progress_bar, ...) βββ decorators # π― Decorators (measure_time, handle_error, timeout, retry, simple_cache, abstract, deprecated, silent) βββ ctx # π Context managers (LogToFile, MeasureTime, Muffle, DoNothing, SetMPStartMethod) βββ io # πΎ Utilities for file management (json_dump, json_load, csv_dump, csv_load, read_file, super_copy, super_open, clean_path, redirect_folder, ...) βββ parallel # π Utility functions for parallel processing (multiprocessing, multithreading, run_in_subprocess) βββ image # πΌοΈ Little utilities for image processing (image_resize, auto_crop, numpy_to_gif, numpy_to_obj) βββ collections # π§° Utilities for collection manipulation (unique_list, at_least_n, sort_dict_keys, upsert_in_dataframe, array_to_disk) βββ typing # π Utilities for typing enhancements (IterAny, JsonDict, JsonList, ..., convert_to_serializable) βββ all_doctests # β Run all doctests for all modules in a given directory (launch_tests, test_module_with_progress) βββ backup # πΎ Utilities for backup management (delta backup, consolidate) βββ lock # π Inter-process FIFO locks (LockFifo, RLockFifo, RedisLockFifo) βββ archive # π¦ Functions for creating and managing archives (create, repair) βββ config # βοΈ Global configuration (StouputilsConfig: global options) β βββ applications/ β βββ automatic_docs # π Documentation generation utilities (used to create this documentation) β βββ upscaler # π Image & Video upscaler (configurable) β βββ ... β βββ continuous_delivery/ β βββ cd_utils # π§ Utilities for continuous delivery β βββ git # π Utilities for local git changelog generation β βββ github # π¦ Utilities for continuous delivery on GitHub (upload_to_github) β βββ pypi # π¦ Utilities for PyPI (pypi_full_routine) β βββ pyproject # π Utilities for reading, writing and managing pyproject.toml files β βββ stubs # π Utilities for generating stub files using stubgen β βββ ... β βββ compression/ β βββ deadband # π Thin a curve down to the points the line drawn through it needs (DeadbandFilter) β βββ ... β βββ mlflow/ β βββ process_metrics_monitor # π Monitor CPU, memory, I/O, and thread metrics for a specific process tree and log them to MLflow β βββ ... β βββ installer/ β βββ common # π§ Common functions used by the Linux and Windows installers modules β βββ downloader # β¬οΈ Functions for downloading and installing programs from URLs β βββ linux # π§ Linux/macOS specific implementations for installation β βββ main # π Core installation functions for installing programs from zip files or URLs β βββ windows # π» Windows specific implementations for installation β βββ ... βββ ...
π Extensive CLI Documentation#
The stouputils CLI provides several powerful commands for common development tasks.
β‘ General Usage#
stouputils <command> [options]
Running stouputils without arguments displays help with all available commands.
π --version / -v - Show Version Information
Display the version of stouputils and its dependencies, along with the used Python version.
# Basic usage - show stouputils version
stouputils --version
stouputils -v
# Show version for a specific package
stouputils --version numpy
stouputils -v requests
# Show dependency tree (depth 3+)
stouputils --version -t 3
stouputils -v stouputils --tree 4
Options:
Option |
Description |
|---|---|
|
Optional package name to show version for (default: stouputils) |
|
Show dependency tree with specified depth (β€2 for flat list, β₯3 for tree view) |
β
all_doctests - Run Doctests
Execute all doctests in Python files within a directory.
# Run doctests in current directory
stouputils all_doctests
# Run doctests in specific directory
stouputils all_doctests ./src
# Run doctests with file pattern filter
stouputils all_doctests ./src "*image/*.py"
stouputils all_doctests . "*utils*"
Arguments:
Argument |
Description |
|---|---|
|
Directory to search for Python files (default: |
|
Glob pattern to filter files (default: |
Exit codes:
0: All tests passed1: One or more tests failed
π¦ archive - Archive Utilities
Create and repair ZIP archives.
# Show archive help
stouputils archive --help
archive make - Create Archive
# Basic archive creation
stouputils archive make ./my_folder ./backup.zip
# Create archive with ignore patterns
stouputils archive make ./project ./project.zip --ignore "*.pyc,__pycache__,*.log"
# Create destination directory if needed
stouputils archive make ./source ./backups/archive.zip --create-dir
Arguments & Options:
Argument/Option |
Description |
|---|---|
|
Source directory to archive |
|
Destination zip file path |
|
Comma-separated glob patterns to exclude |
|
Create destination directory if it doesnβt exist |
archive repair - Repair Corrupted ZIP
# Repair with auto-generated output name
stouputils archive repair ./corrupted.zip
# Repair with custom output name
stouputils archive repair ./corrupted.zip ./fixed.zip
Arguments:
Argument |
Description |
|---|---|
|
Path to the corrupted zip file |
|
Path for repaired file (default: adds |
πΎ backup - Backup Utilities
Create delta backups, consolidate existing backups, and manage backup retention.
# Show backup help
stouputils backup --help
backup delta - Create Delta Backup
Create an incremental backup containing only new or modified files since the last backup.
# Basic delta backup
stouputils backup delta ./my_project ./backups
# Delta backup with exclusions
stouputils backup delta ./project ./backups -x "*.pyc" "__pycache__/*" "node_modules/*"
stouputils backup delta ./source ./backups --exclude "*.log" "temp/*"
Arguments & Options:
Argument/Option |
Description |
|---|---|
|
Source directory or file to back up |
|
Destination folder for backups |
|
Glob patterns to exclude (space-separated) |
backup consolidate - Consolidate Backups
Merge multiple delta backups into a single complete backup.
# Consolidate all backups up to latest.zip into one file
stouputils backup consolidate ./backups/latest.zip ./consolidated.zip
Arguments:
Argument |
Description |
|---|---|
|
Path to the latest backup ZIP file |
|
Path for the consolidated output file |
backup limit - Limit Backup Count
Limit the number of delta backups by consolidating the oldest ones.
# Keep only the 5 most recent backups
stouputils backup limit 5 ./backups
# Allow deletion of the oldest backup (not recommended)
stouputils backup limit 5 ./backups --no-keep-oldest
Arguments & Options:
Argument/Option |
Description |
|---|---|
|
Maximum number of backups to keep |
|
Path to the folder containing backups |
|
Allow deletion of the oldest backup (default: keep it) |
ποΈ build - Build and Publish to PyPI
Build and publish a Python package to PyPI using the uv tool. This runs a complete routine including version bumping, stub generation, building, and publishing.
# Standard build and publish (bumps patch by default)
stouputils build
# Build without generating stubs and without bumping version
stouputils build --no_stubs --no_bump
# Bump minor version before build
stouputils build minor
# Bump major version before build
stouputils build major
Options:
Option |
Description |
|---|---|
|
Skip stub file generation |
|
Skip version bumping (use current version) |
|
Bump minor version (e.g., 1.2.0 -> 1.3.0) |
|
Bump major version (e.g., 1.2.0 -> 2.0.0) |
π changelog - Generate Changelog
Generate a formatted changelog from local git history.
# Show changelog help
stouputils changelog --help
# Generate changelog since latest tag (default)
stouputils changelog
# Generate changelog since a specific tag
stouputils changelog tag v1.9.0
# Generate changelog since a specific date
stouputils changelog date 2026/01/05
stouputils changelog date "2026-01-15 14:30:00"
# Generate changelog since a specific commit
stouputils changelog commit 847b27e
# Include commit URLs from a remote
stouputils changelog --remote origin
stouputils changelog tag v2.0.0 -r origin
# Output to a file
stouputils changelog -o CHANGELOG.md
stouputils changelog tag v1.0.0 --output docs/CHANGELOG.md
Arguments & Options:
Argument/Option |
Description |
|---|---|
|
Mode for selecting commits: |
|
Value for the mode (tag name, date, or commit SHA) |
|
Remote name for commit URLs (e.g., |
|
Output file path (default: stdout) |
Supported date formats:
YYYY/MM/DDorYYYY-MM-DDDD/MM/YYYYorDD-MM-YYYYYYYY-MM-DD HH:MM:SSISO 8601:
YYYY-MM-DDTHH:MM:SS
π redirect - Redirect a Folder
Move a folder to a new location and create a junction or symlink at the original path. Useful for redirecting game installs, large data folders, etc. across drives.
# Show redirect help
stouputils redirect --help
# Redirect with auto-detected basename (destination ends with /)
stouputils redirect "C:/Games/MyGame" "D:/Games/" --hardlink
# Redirect with explicit destination name
stouputils redirect "C:/Games/MyGame" "D:/Storage/MyGame" --symlink
# Interactive mode (asks for link type)
stouputils redirect "./my_folder" "/mnt/external/"
Arguments & Options:
Argument/Option |
Description |
|---|---|
|
Source folder to redirect |
|
Destination path (append |
|
Use NTFS junction (Windows) or fallback to symlink (Linux/macOS) |
|
Use a symbolic link (may need admin on Windows) |
Notes:
If
--hardlinkfails (e.g., unsupported OS), it automatically falls back to symlinkIf the source is already a symlink or junction, the operation is skipped
On Linux/macOS, junctions are not available so
--hardlinkuses a symlink instead
π Examples Summary#
Command |
Description |
|---|---|
|
Show version |
|
Show numpy version with dependency tree |
|
Run doctests in src directory |
|
Create archive |
|
Repair corrupted zip |
|
Create delta backup |
|
Consolidate backups |
|
Keep only 5 backups |
|
Build with minor version bump |
|
Generate changelog to file |
|
Redirect folder with junction |
β Star History#
Module Documentation#
- stouputils package
- Subpackages
- stouputils.all_doctests package
- stouputils.applications package
- Subpackages
- stouputils.applications.automatic_docs package
- Subpackages
- stouputils.applications.automatic_docs.sphinx package
- Subpackages
- Submodules
- stouputils.applications.automatic_docs.sphinx.builder module
- stouputils.applications.automatic_docs.sphinx.conf_file module
- stouputils.applications.automatic_docs.sphinx.forges module
- stouputils.applications.automatic_docs.sphinx.index_page module
- stouputils.applications.automatic_docs.sphinx.theming module
- stouputils.applications.automatic_docs.sphinx package
- Submodules
- Subpackages
- stouputils.applications.upscaler package
- Submodules
- stouputils.applications.upscaler.config module
WAIFU2X_NCNN_VULKAN_RELEASESFFMPEG_RELEASESYOUTUBE_BITRATE_RECOMMENDATIONSConfigConfig.JPG_QUALITYConfig.VIDEO_FINAL_BITRATEConfig.FFMPEG_EXECUTABLEConfig.FFMPEG_ARGSConfig.FFPROBE_EXECUTABLEConfig.FFMPEG_CHECK_HELP_TEXTConfig.UPSCALER_EXECUTABLEConfig.UPSCALER_ARGSConfig.UPSCALER_EXECUTABLE_HELP_TEXTConfig.SLIGHTLY_FASTER_MODEConfig.upscaler_executable_checkedConfig.ffmpeg_executable_checked
- stouputils.applications.upscaler.image module
- stouputils.applications.upscaler.video module
- stouputils.applications.upscaler.config module
- Submodules
- stouputils.applications.automatic_docs package
- Subpackages
- stouputils.archive package
- Subpackages
- stouputils.archive.repair package
- Submodules
- stouputils.archive.repair.repair module
RecoveredArchiveRecoveredArchive.METADATA_NAMERecoveredArchive.SUPPORTED_METHODSRecoveredArchive.scannerRecoveredArchive.zip_fileRecoveredArchive.seen_namesRecoveredArchive.entry_indexRecoveredArchive.unique_name()RecoveredArchive.write()RecoveredArchive.write_central_entry()RecoveredArchive.recover_metadata()
repair_zip_file()
- stouputils.archive.repair.scanner module
LocalHeaderCentralEntryZipScannerZipScanner.LOCAL_SIGNATUREZipScanner.CENTRAL_SIGNATUREZipScanner.EOCD_SIGNATUREZipScanner.LOCAL_HEADER_SIZEZipScanner.CENTRAL_HEADER_SIZEZipScanner.UTF8_NAME_FLAGZipScanner.SEARCH_BACKWARDZipScanner.SEARCH_FORWARDZipScanner.dataZipScanner.signature_positionsZipScanner.sizeZipScanner.find_all()ZipScanner.next_signature()ZipScanner.decode_name()ZipScanner.sanitize_name()ZipScanner.find_local_header_near()ZipScanner.read_local_header()ZipScanner.decode_range()ZipScanner.extract_content()ZipScanner.central_entries()
- stouputils.archive.repair.repair module
- Submodules
- stouputils.archive.repair package
- Submodules
- Subpackages
- stouputils.backup package
- stouputils.collections package
- stouputils.compression package
- stouputils.continuous_delivery package
- Submodules
- stouputils.continuous_delivery.cd_utils module
- stouputils.continuous_delivery.git module
- stouputils.continuous_delivery.github module
- stouputils.continuous_delivery.gitlab module
- stouputils.continuous_delivery.pypi module
- stouputils.continuous_delivery.pyproject module
- stouputils.continuous_delivery.release_common module
PlatformConfigPlatformConfig.base_urlPlatformConfig.project_identifierPlatformConfig.headersPlatformConfig.versionPlatformConfig.build_folderPlatformConfig.endswithPlatformConfig.project_api_urlPlatformConfig.web_urlPlatformConfig.tag_api_pathPlatformConfig.commit_api_pathPlatformConfig.release_api_pathPlatformConfig.commit_url_pathPlatformConfig.compare_url_pathPlatformConfig.platform_name
validate_required_keys()check_existing_tag()prompt_delete_existing()handle_existing_tag()fetch_latest_tag()paginate_api()fetch_commits_since_tag()generate_changelog()upload_files()log_success()delete_resource()delete_resource_unconditional()create_tag_on_branch()create_release()publish_release()
- Submodules
- stouputils.ctx package
- stouputils.decorators package
- Submodules
- stouputils.decorators.abstraction module
- stouputils.decorators.caching module
- stouputils.decorators.common module
- stouputils.decorators.deprecation module
- stouputils.decorators.error_handling module
- stouputils.decorators.retrying module
- stouputils.decorators.silencing module
- stouputils.decorators.timeouts module
- stouputils.decorators.timing module
- Submodules
- stouputils.image package
- stouputils.installer package
- stouputils.io package
- stouputils.lock package
- Usage
- Submodules
- stouputils.lock.base module
_lock_fd()_unlock_fd()_remove_file_if_unlocked()_worker()_hold()LockFifoLockFifo.pathLockFifo.timeoutLockFifo.blockingLockFifo.check_intervalLockFifo.fileLockFifo.fdLockFifo.is_lockedLockFifo.memberLockFifo.fifoLockFifo.fifo_stale_timeoutLockFifo.queue_dirLockFifo._abc_implLockFifo.get_ticket()LockFifo._cleanup_stale_tickets()LockFifo.perform_lock()LockFifo.acquire()LockFifo.release()LockFifo.close()
- stouputils.lock.queue module
- stouputils.lock.re_entrant module
- stouputils.lock.redis_fifo module
- stouputils.lock.shared module
- stouputils.lock.base module
- stouputils.mlflow package
- Submodules
- stouputils.mlflow.process_metrics_monitor module
ProcessMetricsMonitorProcessMetricsMonitor.pidProcessMetricsMonitor.childrenProcessMetricsMonitor.sampling_intervalProcessMetricsMonitor.samples_before_loggingProcessMetricsMonitor.prefixProcessMetricsMonitor.verboseProcessMetricsMonitor.max_memory_megabytesProcessMetricsMonitor.max_cpu_countProcessMetricsMonitor.deadband_filterProcessMetricsMonitor.run_idProcessMetricsMonitor.shutdown_eventProcessMetricsMonitor.threadProcessMetricsMonitor._abc_implProcessMetricsMonitor.stepProcessMetricsMonitor.processesProcessMetricsMonitor.start()ProcessMetricsMonitor.finish()ProcessMetricsMonitor.collect_once()ProcessMetricsMonitor.aggregate()ProcessMetricsMonitor.publish()ProcessMetricsMonitor.write()ProcessMetricsMonitor.monitor_loop()
- stouputils.mlflow.process_metrics_monitor module
- Submodules
- stouputils.parallel package
- stouputils.print package
- Submodules
- stouputils.print.color_formatting module
- stouputils.print.colorizer module
WordColorizerWordColorizer.colorWordColorizer.EXCEPTION_NAMESWordColorizer.BUILTIN_FUNCTIONSWordColorizer.KEYWORDSWordColorizer.AFFIX_PATTERNWordColorizer.QUOTED_PATTERNWordColorizer.NUMBER_PATTERNWordColorizer.WORD_SPLIT_PATTERNWordColorizer.wrap()WordColorizer.is_filepath()WordColorizer.is_number()WordColorizer.alphanumeric_of()WordColorizer.function_name_of()WordColorizer.colorize_function()WordColorizer.colorize_core()WordColorizer.colorize_word()WordColorizer.colorize_text()
- stouputils.print.common module
- stouputils.print.debugging module
- stouputils.print.message module
- stouputils.print.output_stream module
- stouputils.print.progress_tqdm module
- stouputils.print.utils module
- Submodules
- Submodules
- stouputils.__main__ module
- stouputils._deprecated module
- stouputils.config module
StouputilsConfigStouputilsConfig.VERBOSE_READING_ENVStouputilsConfig.RESETStouputilsConfig.BLACKStouputilsConfig.LIGHT_GRAYStouputilsConfig.GRAYStouputilsConfig.REDStouputilsConfig.GREENStouputilsConfig.YELLOWStouputilsConfig.BLUEStouputilsConfig.MAGENTAStouputilsConfig.CYANStouputilsConfig.WHITEStouputilsConfig.LINE_UPStouputilsConfig.BOLDStouputilsConfig.BAR_FORMATStouputilsConfig.FORCE_RAISE_EXCEPTIONStouputilsConfig.CPU_COUNTStouputilsConfig.MEMORY_MEGABYTESStouputilsConfig.PROCESS_TITLE_PER_WORKERStouputilsConfig.CHUNK_SIZEStouputilsConfig.LARGE_CHUNK_SIZEStouputilsConfig.COMMIT_TYPESStouputilsConfig.AUTO_DOCS_REQUIREMENTSStouputilsConfig.SEGMENTS_UNIQUE_COLORStouputilsConfig.SEGMENTS_COLOR_CYCLE
- stouputils.lazy module
- stouputils.system module
- stouputils.typing module
- stouputils.version_pkg module
VersionPrinterVersionPrinter.main_packageVersionPrinter.primary_colorVersionPrinter.secondary_colorVersionPrinter.max_depthVersionPrinter.fully_displayedVersionPrinter.version_of()VersionPrinter.dependency_name()VersionPrinter.dependencies_of()VersionPrinter.separators()VersionPrinter.minimum_widthVersionPrinter.package_line()VersionPrinter.already_shown_line()VersionPrinter.indent_block()VersionPrinter.render_tree()VersionPrinter.print_tree()VersionPrinter.print_flat()VersionPrinter.show()
show_version()show_version_cli()
- Subpackages