Skip to main content

Contributors Forks Stargazers Issues MIT License

About The Project

Overview

This package was created by factoring out many reusable code artifacts from my various projects over a number of years. Since this work was not a part of a group effort, the test coverage is predictably abysmal 🤨 and Python documentation notably absent 😑. For each of my projects, which derive from a common Docker application found here, this package provides some specific and relatively powerful features to enable rapid offshoots for new ideas.

The package is organized under src/tailucas_pylib/ with the following key modules:

  • Core Modules:

    • __init__.py: Application bootstrap with logging, locale, configuration (via app.conf), and device name setup. Logs to syslog (UDP) or stdout/stderr. Optionally changes working directory to WORK_DIR.
    • creds.py: 1Password credential management supporting both 1Password Connect Server and 1Password Service Account modes. Fetches secrets from environment variables or container secrets (/run/secrets).
    • flags.py: Feature flag checking backed by a 1Password credential item.
  • Application Framework:

    • app.py: Thread base class with ZMQ relay (ZmqRelay) and worker (ZmqWorker) patterns for inter-thread communication via ZeroMQ.
    • threads.py: Thread nanny with shutdown tracking, graceful termination, and lingering socket cleanup.
    • handler.py: Context manager (exception_handler) that handles ZMQ connectivity, ContextTerminated, ResourceWarning, and general exceptions with optional OpenTelemetry exception tracing and graceful shutdown.
    • process.py: Signal handler (SignalHandler) with subprocess execution (exec_cmd) helpers.
  • Communication:

    • rabbit.py: RabbitMQ integration with MQConnection, ZMQListener (consumes RabbitMQ messages and forwards to ZMQ), and RabbitMQRelay (bridges ZMQ to RabbitMQ).
    • zmq.py: ZeroMQ socket creation, lifecycle management (Closable), and graceful context teardown.
  • Utilities:

    • data.py: Builds MessagePack payloads with timestamp and optional data for IPC.
    • datetime.py: Timezone-aware timestamp creation, ISO formatting, and Unix timestamp conversion.
    • device.py: Dataclass data model (Device) for device state with optional fields.
    • bluetooth.py: Bluetooth adaptor detection and device ping via hcitool / l2ping.
  • AWS Integration (aws/):

    • __init__.py: Manages cached Boto3 sessions with STS role assumption, credential retrieval from 1Password.
    • metrics.py: Posts CloudWatch count metrics with dimensions.
  • Command-line Tools (tools/):

    • config_interpol.py: Interpolates a config file with environment variables or an overlay config, outputting the resolved values.
    • cred_tool.py: Fetches and displays a 1Password credential read from stdin.
    • yaml_interpol.py: Processes YAML templates, substituting values from configuration sections.
    • aws_configure.py: Generates AWS CLI configuration files from 1Password-stored credentials.

(back to top)

Built With

Technologies that help make this package useful:

1Password Amazon AWS uv Python RabbitMQ ZeroMQ

Also:

GitHub

Core Technologies:

  • Python 3.11+ - Primary runtime
  • 1Password Connect/Service Account - Credential management
  • ZeroMQ - Inter-process communication
  • RabbitMQ - Message queuing
  • MessagePack - Binary serialization
  • Pydantic - Data validation and modeling
  • OpenTelemetry - Error tracking and monitoring

AWS Integration:

  • Boto3 - AWS SDK
  • CloudWatch - Metrics and monitoring
  • Simple Workflow Service - Workflow orchestration (deprecated)

Development Tools:

  • uv - Dependency management

(back to top)

Getting Started

Here is some detail about the intended use of this package.

Prerequisites

A Python project or runtime environment. Since this project is already initialized with uv dependency management, I recommend that you continue to use it. Beyond the Python dependencies defined in the configuration, the package init carries a hardcoded dependency on 1Password in order to function. Unless you want this and are effectively extending my base project, you're likely better off forking this package and cutting out what you do not need.

Installation

This package is published to the Python Package index from time to time.

Updating dependencies

Dependency upgrades are driven entirely by uv; uv.lock is the single source of truth for resolved versions. The full upgrade is four commands, also available as make update:

# upgrade every package in the lockfile (core deps, all extras, all groups)
uv lock --upgrade

# install everything the project defines from the new resolution
uv sync --all-extras --all-groups

# verify the lockfile and the environment match pyproject.toml
uv lock --check
uv sync --check --all-extras --all-groups

# verify the package still builds with the pinned build backend
uv build

Narrower and favourite-option variants of the resolution step (uv lock):

Goal Command
Upgrade one package uv lock --upgrade-package boto3
Upgrade one dependency group (lint, test, dev) uv lock --upgrade-group test
Preview without writing uv lock --upgrade --dry-run
Ignore cached index data uv lock --upgrade --refresh (or --no-cache)
Allow pre-releases uv lock --upgrade --prerelease allow (env: UV_PRERELEASE=allow)
Prefer oldest resolvable versions (lower-bound audit only, --dry-run; oldest releases fail to build on 3.14) uv lock --upgrade --resolution lowest-direct --dry-run
Freeze to a release date (supply-chain safety) uv lock --upgrade --exclude-newer 2026-10-01
Upgrade uv itself uv self update

Two things are outside uv lock's reach:

  • Version bounds. uv lock --upgrade only selects versions satisfying the bounds in pyproject.toml. Widen a bound in the same change when a newer release falls outside it (for example boto3>=1.43.123), otherwise that dependency silently stops moving.
  • The build backend. uv_build is pinned in [build-system], is not recorded in uv.lock, and is resolved only at build time. Bump it by hand to the current uv release line and re-verify uv build plus the publish path (uvx --from build pyproject-build --outdir dist .).

Then bump the patch version in pyproject.toml (repo convention for dependency-only changes; a breaking change needs a minor bump) and run the gate from Testing — make lint test covers the lint gates and the core suite.

(back to top)

Usage

I have various projects that use this tool chain. For example, my Base Project which can be run stand-alone but also serves as my Docker base image from which other projects are derived.

(back to top)

Testing

Tests use pytest with coverage. Some tests exercise live services (1Password Connect Server or Service Account, AWS session setup) and expect the OP_CONNECT_HOST, OP_CONNECT_TOKEN, OP_VAULT and OP_SERVICE_ACCOUNT_TOKEN environment variables. For deterministic results regardless of the ambient environment, the suite pins TZ=UTC and APP_NAME=test itself (see conftest.py).

Quick run (all extras)

uv sync --all-extras
uv run pytest

Extras matrix

Optional dependencies are organized as extras (aws, creds, monitoring, mq). Using a Hatch matrix, the full test suite also runs against every combination of these extras: 32 environments, each installing the package with only that combination's dependencies.

# list the 32 test environments
uv run hatch env show
# run the whole matrix (stops at the first failing environment)
uv run hatch run test:run
# run a single combination
uv run hatch run test.aws-no-creds-no-monitoring-mq:run
# remove all cached test environments
uv run hatch env prune

Tests that require an unavailable optional dependency skip themselves via pytest.importorskip, so every combination runs as much of the suite as its installed extras allow. Per-environment coverage data is written to .coverage.<env-name>.

Note that a full matrix run executes the live 1Password tests many times over, and the 1Password service-account API rate limit is shared across them. An occasional RateLimitExceeded failure during a full run is transient; re-run the affected environment to confirm.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Acknowledgments

(back to top)

Metadata

Release files for tailucas-pylib 0.8.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tailucas-pylib 0.8.5
File Size Uploaded Provenance Actions
tailucas_pylib-0.8.5.tar.gz 25.9 kB Without provenance Details for tailucas_pylib-0.8.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tailucas-pylib 0.8.5
File Interpreter ABI Platform Actions
tailucas_pylib-0.8.5-py3-none-any.whl Python 3 none any Details for tailucas_pylib-0.8.5-py3-none-any.whl

Total release size: 56.2 kB

Release files / tailucas_pylib-0.8.5.tar.gz

Download URL tailucas_pylib-0.8.5.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3d2f8379cb728158cbc79364cb1d1762811f3f3bbce14763cfcd7ed791acdbda
BLAKE2b-256 checksum
How to use checksums
8a6e5539165543abc84ae4a0c80eed94447153fd111e226bdc60764843d9a024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / tailucas_pylib-0.8.5-py3-none-any.whl

Download URL tailucas_pylib-0.8.5-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
006d9f2cb04562ef628248d299988b2fe67cc545bc5fc0b22d0bf4be9cd01d3e
BLAKE2b-256 checksum
How to use checksums
ae833c34cba8fd7f4165450a1abeb93261e27e919b83b0434f0de8371ad221cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for tailucas-pylib 0.8.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.8.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page