Metadata-Version: 2.4
Name: ingot-mail
Version: 0.1.0
Summary: The mail of Ingots applications.
Keywords: ingots,mail,email
Author: Aliaksandr Karotki
Author-email: Aliaksandr Karotki <abkarotki@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Requires-Dist: ingots>=0.34.0,<0.35
Requires-Python: >=3.14
Project-URL: repository, https://github.com/ak-ingots/ingot-mail
Project-URL: changelog, https://github.com/ak-ingots/ingot-mail/blob/main/CHANGELOG.md
Description-Content-Type: text/markdown

# ingot-mail

[![ci](https://github.com/ak-ingots/ingot-mail/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ak-ingots/ingot-mail/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/ak-ingots/ingot-mail/blob/main/LICENSE)

<!-- Links must be absolute: this README also renders on PyPI. -->

The mail of Ingots applications. An addon of
[Ingots](https://github.com/ak-ingots/ingots).

**Status:** pre-alpha: the skeleton, its project with the settings, the
logging and the mail units; nothing is sent yet.

## For Consumers

### Install

```sh
uv add ingot-mail
```

### Integrate

An application of Ingots has its own configs, settings, logging and project;
each takes the class of the addon among its bases:

```python
# app/project.py
import typing as t

from ingot_mail import MailProject
from ingot_mail.logging import MailLoggingUnit
from ingot_mail.settings import MailSettingsUnit
from ingot_mail.settings.configs import MailConfigs
from ingots.puer import Slot


class AppConfigs(MailConfigs):
    pass


class AppSettingsUnit(MailSettingsUnit):
    configs = Slot(AppConfigs)


class AppLoggingUnit(MailLoggingUnit):
    project: "AppProject"


class AppProject(MailProject):
    env_configs_prefix = "APP"
    settings = Slot(AppSettingsUnit)
    logging = Slot(AppLoggingUnit)
```

With other addons, their classes join the same bases:
`class AppConfigs(MailConfigs, MongoDbConfigs)`, and so on, as the
[addon guide](https://github.com/ak-ingots/ingots/blob/main/docs/defaults/addon.md)
of Ingots shows. An application with this addon alone may inherit
`MailProject` and nothing more.

The application runs through its own `__main__.py`:

```python
# app/__main__.py
import sys

from ingots.defaults.logging import configure_startup_logging
from ingots.puer.cli import CommandRunner

from .project import AppProject

configure_startup_logging()
sys.exit(CommandRunner(AppProject).run())
```

```sh
uv run python -m app settings list    # the configs, MAIL_* among them
uv run python -m app logging info     # the loggers, ingot_mail among them
```

### Configs

Set as environment variables with the prefix of the project
(`APP_MAIL_LOGGING_LEVEL`), in a `--configs-file` or with `--config`.

| Name | Default | Meaning |
|---|---|---|
| `MAIL_LOGGING_LEVEL` | `INFO` | the level of the logger of the addon, `ingot_mail` |

## Development

Requires [uv](https://docs.astral.sh/uv/) and `make`; uv fetches the
interpreters it needs.

```sh
make                 # the target list
make check           # everything CI runs: lint, test, coverage, wheel-test, cl-check
make format          # black
make all             # build the sdist and the wheel into dist/
```

- Every change users should know about adds a news fragment to `changelog.d/`
  (see [its README](https://github.com/ak-ingots/ingot-mail/blob/main/changelog.d/README.md)).
- A release is a pull request setting the version (`uv version X.Y.Z`) and
  collating the changelog (`make cl-build VERSION=X.Y.Z`), then the tag
  `vX.Y.Z` on `main`: the `release` workflow publishes the tested build to
  TestPyPI, tests it as installed from there, then
  publishes it to PyPI. Run by hand, it rehearses on TestPyPI only.
