Skip to main content

Professional build automation for EmbedDesire Python applications

Project description

EmbedDesire - Professional Python Asset Embedding

embdes is a production-ready tool for embedding static resources (images, sounds, text files) directly into Python applications and building standalone executables with PyInstaller.

Features

  • Embed resources into Python applications with optional compression
  • Automatic extraction with built-in caching (100% cache hit rate)
  • Development/Runtime modes - embed during dev, extract in exe
  • PyInstaller integration - automated build process
  • Persistent storage - save embedded data for exe distribution
  • Production-ready - comprehensive logging, validation, error handling
  • Cross-platform - Windows, macOS, Linux support
  • Global CLI - callable from any directory as embdes command

Installation

pip install embdes

Quick Start

1. Embed Resources in Your App

from embeddesire import embed, set_runtime_mode

# Development: embed files
set_runtime_mode(False)
embed("resources/", id="my_resources", compress=True)

# Your app code here
from embeddesire import extract
resources = extract("my_resources", output_path="./temp")

2. Build Executable with Embedded Resources

embdes app.py --onefile -w

This automatically:

  • Scans for embed() calls in your code
  • Executes your app to populate embedded data
  • Saves data to pickle file
  • Builds PyInstaller exe with embedded resources included
  • Cleans up temporary files

API Reference

embeddesire.py

embed(path, id, compress=True)          # Embed file/folder
extract(id, output_path=None)           # Extract with caching
set_runtime_mode(value)                 # Switch dev/runtime
save_embedded(file_path)                # Persist to pickle
load_embedded(file_path)                # Load from pickle
clear_cache()                           # Clear extraction cache
get_cache_stats()                       # Get cache info
get_embedded_resources()                # List all resources
remove_embedded_resource(id)            # Remove resource

embdes.py (CLI)

embdes <script.py> [pyinstaller_args...]

# Examples:
embdes app.py                           # Basic build
embdes app.py --onefile                # Single-file exe
embdes app.py -w --icon=app.ico        # Windowed with icon
embdes app.py --help                   # Show help

Configuration

Both modules support environment variables:

# Compression level (0-9, default 6)
export EMBEDDESIRE_COMPRESSION_LEVEL=9

# Maximum file size (default 100MB)
export EMBEDDESIRE_MAX_FILE_SIZE=50000000

# Cache size (default 500MB)
export EMBEDDESIRE_MAX_CACHE_SIZE=250000000

# PyInstaller path (auto-detected by default)
export EMBEDDESIRE_PYINSTALLER_PATH=/path/to/pyinstaller

# Build output directory
export EMBEDDESIRE_OUTPUT_DIR=./dist

# One-file build (true/false)
export EMBEDDESIRE_ONE_FILE=true

Performance

  • Cache Hit Rate: 100% for repeated extractions of same resource
  • Compression: Configurable zlib (default level 6)
  • Serialization: Python pickle HIGHEST_PROTOCOL
  • Extraction: Cached in memory after first extraction

Error Handling

Custom exceptions for debugging:

from embeddesire import (
    EmbedDesireError,
    EmbedError,
    ExtractError,
    PersistenceError,
    ValidationError
)

try:
    extract("nonexistent")
except ExtractError as e:
    print(f"Extraction failed: {e}")

Logging

from embeddesire import configure_logging, LogLevel

configure_logging(LogLevel.DEBUG)  # Enable debug logging

Testing

Unit tests are included. Run with:

pytest tests/

Requirements

  • Python 3.7+
  • PyInstaller (for building executables)

License

MIT License - See LICENSE file (Modified)

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

embdes-1.0.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embdes-1.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file embdes-1.0.1.tar.gz.

File metadata

  • Download URL: embdes-1.0.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for embdes-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ea7df4398d342d244349e84aa805f33e771203957471c8140780561f5b58ad2e
MD5 4f3081e7031bc1bf18d0550dc024d0db
BLAKE2b-256 b36024ad5f86727691b518781500ba6a8764d2550123c69ff1ba6d2a4e2163e8

See more details on using hashes here.

File details

Details for the file embdes-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: embdes-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for embdes-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2014fde3253b4f898df2c6d75b50cdc8c36859d406d4b86211c6baba80a11b5a
MD5 5bdb4fe39776640bd132575887c23170
BLAKE2b-256 b1d91b5634a3f7815f9c6856371e1982a1c43b9eab80778640c4ec98edce6332

See more details on using hashes here.

Supported by

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