A modern Python interface for sending macOS iMessages via AppleScript.
Project description
macpymessenger
macpymessenger is a modern, strongly typed Python toolkit for orchestrating macOS iMessage automation through AppleScript. The library focuses on clear composition, predictable data flow, and modular design so that message sending, template management, and configuration remain easy to reason about and extend.
Features
- Deterministic
Configurationthat validates the packaged AppleScript before use. - Composable
TemplateManagerpowered by Jinja2 with in-memory storage for safe inheritance and inclusion. - Dependency-injected
IMessageClientthat isolates subprocess execution for straightforward testing. - Type-driven API surface with explicit error handling and no hidden global state.
Installation
macpymessenger is published on PyPI. You can install it with Astral's uv (recommended) or with pip.
uv pip install macpymessenger
# or
pip install macpymessenger
The package targets Python 3.10 and newer.
Quick start
from macpymessenger import Configuration, IMessageClient, TemplateManager
configuration = Configuration()
client = IMessageClient(configuration)
client.create_template("welcome", "Hello, {{ name }}! Welcome aboard.")
client.send_template("+15555555555", "welcome", {"name": "Ada"})
Templates are stored in-memory and rendered via Jinja2. They support inheritance and inclusion without touching the filesystem unless you opt into loading a directory of templates.
Configuration
from pathlib import Path
from macpymessenger import Configuration
configuration = Configuration(Path("/path/to/custom/sendMessage.scpt"))
Configuration will raise ScriptNotFoundError if the AppleScript is missing, keeping runtime failures obvious.
Development workflow
This repository is now managed with uv. The following commands assume you have uv installed:
uv sync # install dependencies into the local virtual environment
uv run ruff check # lint the codebase
uv run mypy # static type analysis
uv run pytest # run the automated tests
Each command runs inside the isolated environment declared in pyproject.toml, ensuring reproducible tooling without polluting the global interpreter.
License
macpymessenger is available under the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macpymessenger-0.2.0.tar.gz.
File metadata
- Download URL: macpymessenger-0.2.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bef3f8b03bc20cfc1533acf9d96208cd65e706273cff56c3fb4f30280cab1db0
|
|
| MD5 |
b3c7e5b26f9da7d86195c3bf48b0a1c1
|
|
| BLAKE2b-256 |
3946b0b6cb382eb8b90645660f8d80e2e908ee013c4345b7b0f2f9581cd06178
|
File details
Details for the file macpymessenger-0.2.0-py3-none-any.whl.
File metadata
- Download URL: macpymessenger-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
581f27085f6f3c71b53ea2062add2e2c061b62e62f958f981ec0d37452898e4a
|
|
| MD5 |
4b0eff854302cf7f6e6030c31477e8d3
|
|
| BLAKE2b-256 |
5589f93fbe2e729e979c3cbf6708a977fe0ba4572dd82b8bed0c9f694dea47ae
|