Metadata-Version: 2.5
Name: datastreamcorelib
Version: 1.8.0
Summary: Helpers and utilities for https://gitlab.com/advian-oss/python-datastreamservicelib that are not eventloop specific.
Project-URL: Homepage, https://gitlab.com/advian-oss/python-datastreamcorelib/
Project-URL: Repository, https://gitlab.com/advian-oss/python-datastreamcorelib/
Author-email: Eero af Heurlin <eero.afheurlin@iki.fi>
License-Expression: MIT
License-File: LICENSE
Requires-Python: <4.0,>=3.12
Requires-Dist: libadvian<2.0,>=1.9.0
Requires-Dist: msgpack<2.0,>=1.2.4
Description-Content-Type: text/x-rst

=================
datastreamcorelib
=================

Core message types and abstract base classes for ZeroMQ event loop adapters.

CI tests Python 3.12, 3.13, 3.14, and 3.15.

For an asyncio adapter, see https://gitlab.com/advian-oss/python-datastreamservicelib.
For a service template, see https://gitlab.com/advian-oss/python-datastreamserviceapp_template.

Local development
-----------------

Install uv_. Create the development environment with Python 3.12 to check
compatibility with the oldest supported version::

    uv sync --locked --python 3.12
    uv run --locked prek install --install-hooks
    uv run --locked prek run --all-files
    uv run --locked pytest

.. _uv: https://docs.astral.sh/uv/getting-started/installation/

To change the interpreter, run ``uv sync --locked --python 3.14``.
The hooks use Ruff for linting and formatting, Pyrefly for type checking,
and Bandit for security checks. Run each check directly when necessary::

    uv run --locked ruff check src tests
    uv run --locked ruff format --check src tests
    uv run --locked pyrefly check
    uv run --locked bandit -r src

Run ``uv lock`` after you change dependencies. Commit ``pyproject.toml`` and
``uv.lock`` together. Run ``uv build`` to build the wheel and source distribution.

Version bumps
^^^^^^^^^^^^^

Preview and apply a patch version bump::

    uv run --locked bump-my-version bump patch --dry-run -v
    uv run --locked bump-my-version bump patch
    uv lock
    uv build

The bump updates the project metadata, the package version, the version test,
and the image tags in this README. Review the changes before you commit them.

Containers
----------

``Dockerfile`` uses Debian Trixie. ``Dockerfile_alpine`` uses Alpine 3.24.
Both provide the ``test``, ``tox``, ``devel_shell``, and ``production`` targets.
Both production images use Python 3.14.

Run the container checks with Docker or Podman::

    CONTAINER_ENGINE=docker ./run_tests.sh
    CONTAINER_ENGINE=podman ./run_tests.sh

To check one variant and target, set ``VARIANTS`` and ``TARGETS``::

    CONTAINER_ENGINE=podman VARIANTS=debian TARGETS=tox ./run_tests.sh

The script builds from a copy of the source. It uses the package index by
default. To add a wheelhouse, set ``WHEELHOUSE_URL``::

    VARIANTS=debian WHEELHOUSE_URL=http://host.docker.internal:3141/debian/ ./run_tests.sh

Use the wheelhouse URL for the selected distribution. The script maps
``host.docker.internal`` to the host gateway.

Development shell
^^^^^^^^^^^^^^^^^

Build and start a shell::

    docker build --target devel_shell -t datastreamcorelib:devel_shell .
    docker run --rm -it datastreamcorelib:devel_shell

For Podman, replace ``docker`` with ``podman``. Add ``--format docker`` to
the build command. Run ``uv run --locked pytest`` inside the shell.
Rebuild the image to include source edits.

Tox
^^^

Run the tox image with no arguments to test all four Python versions.
To test one version, pass its tox environment name::

    docker build --target tox -t datastreamcorelib:tox .
    docker run --rm datastreamcorelib:tox -e py314

Production
^^^^^^^^^^

Build and run an image with the installed library::

    docker build --target production -t datastreamcorelib:1.8.0 .
    docker run --rm datastreamcorelib:1.8.0

The default command prints the package version. Pass a different command to
use the installed library from another program.

Continuous integration
----------------------

GitLab runs the Python test matrix and builds the wheel and source
distribution. It also checks all four container targets on Debian and Alpine.
The container jobs require a privileged Docker-in-Docker runner with shared
TLS certificates.
