charmlibs-pathops
A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
What it is and what it does
charmlibs-pathops is a filesystem abstraction library for Juju Charms that unifies file operations across local charm containers and remote workload containers. It wraps the ops framework and provides LocalPath and ContainerPath classes that implement a common PathProtocol interface—a subset of pathlib.Path—allowing charm code to work with either filesystem using identical method calls.
The library is designed for Kubernetes charms that need to read from or write to files in both the charm container and the workload container. It handles path operations like mkdir, read_bytes, write_text, and a helper ensure_contents function that idempotently sets file contents and reports whether changes were made. It does not support relative paths, the open method, or symlink/hardlink manipulation; mkdir, write_bytes, and write_text accept mode, user, and group parameters to set permissions and ownership directly.
Use it for:
- Copy configuration files from a charm container to a workload container with permission and ownership control.
- Write charm-generated configuration to a workload container and detect whether the workload needs to reload.
- Implement charm logic that works identically on both machine and Kubernetes charms by accepting a PathProtocol argument.
- Ensure a file exists with specific content and ownership in a workload container, idempotently.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a pathlib-like interface for reading and writing files in local filesystems and Juju workload container paths, supporting both Kubernetes and machine charms.
Yes—if you are writing Juju Charms that need to interact with container filesystems. The library eliminates boilerplate for path handling and unifies the API across charm types. No known vulnerabilities, permissive license, low install friction, and active maintenance. Not relevant for non-charm Python projects.
Install
charmlibs-pathops on PyPI
pip
pip install charmlibs-pathopsuv
uv add charmlibs-pathopspoetry
poetry add charmlibs-pathopsInstalling charmlibs-pathops
Before you install
Low friction: pure Python wheel with a single runtime dependency (ops). Active maintenance with recent releases; last commit 2026-08-14.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
from charmlibs import pathops
import ops
class KubernetesCharm(ops.CharmBase):
def __init__(self, framework: ops.Framework):
super().__init__(framework)
container = self.unit.get_container('container-name')
self.root = pathops.ContainerPath('/', container=container)
path = self.root / 'foo/bar'
path.write_text('content')
Requires Python >=3.10 and ops as a runtime dependency.
Verify before relying
- Whether PathProtocol's subset of pathlib.Path API covers typical charm file-handling workflows beyond the documented examples.
- Performance characteristics when working with large files or many operations across container boundaries.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — ops |
| Maintenance | actively maintained — 59 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 80,338/month — #14,296 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: charmlibs_pathops-1.3.0.post0-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
opsA Python framework for developing…
permissive · top 15,000 on PyPI
coslProvides utilities for COS Lite charms,…
permissive · top 15,000 on PyPI
jujuA Python library providing asynchronous…
permissive · top 15,000 on PyPI
jubilantJubilant wraps the Juju CLI with a…
permissive · top 15,000 on PyPI
ops-scenarioops-scenario is a state-transition testing…
permissive · top 15,000 on PyPI
charmcraftlocalPacks Juju charms with local Python package…
unclear · top 15,000 on PyPI
pytest-operatorA pytest plugin that provides fixtures and…
permissive · top 15,000 on PyPI
path.pyProvides Path objects that wrap filesystem…
permissive · top 15,000 on PyPI
data-platform-helpersProvides version checking and validation…
permissive · top 15,000 on PyPI
skia-pathopsPython bindings for Google Skia's Path Ops…
permissive · top 15,000 on PyPI