1
0
Fork 0
sops python wrapper library http://sopsy.nikaro.net
Find a file
2026-02-10 21:46:48 +01:00
docs docs: inject readme into index 2024-09-09 10:33:37 +02:00
src/sopsy ci: swtich to mypy 2025-07-26 21:28:59 +02:00
tests feat: allow to handle data from stdin 2025-07-02 07:48:29 +02:00
.codebook.toml chore: migrate from github to sourcehut 2025-07-26 23:31:51 +02:00
.editorconfig ci: switch from makefile to taskfile 2024-08-11 19:00:38 +02:00
.gitignore ci: enable codecov test analytics 2024-09-09 13:58:04 +02:00
.readthedocs.yaml docs: build documentation with sphinx 2024-09-07 00:26:18 +02:00
AGENTS.md chore: add AGENTS.md instructions 2026-02-10 21:43:06 +01:00
CHANGELOG.md bump: version 1.2.0 → 1.2.1 2025-07-26 19:31:06 +00:00
LICENSE chore: change license from gpl-3 to mit 2024-11-18 16:18:35 +01:00
mkdocs.yml docs: inject readme into index 2024-09-09 10:33:37 +02:00
prek.toml ci: rename prek config file 2026-02-10 21:28:29 +01:00
pyproject.toml chore: switch tp uv build backend 2026-02-10 21:42:48 +01:00
README.md chore: migrate from github to sourcehut 2025-07-26 23:31:51 +02:00
Taskfile.yml chore: run commitizen through uv 2026-02-10 21:30:02 +01:00
uv.lock chore: add commitizen dev deps 2026-02-10 20:49:53 +01:00

SOPSy

Python Version from PEP 621 TOML PyPI - Version PyPI - Downloads builds.sr.ht status Ceasefire Now

SOPSy is a simple Python wrapper around SOPS.

Installation

SOPS binary must be installed and available in your $PATH:

# use your package manager to install it
brew install sops

Install the SOPSy library:

pip install sopsy

# or with whatever your package/project manager is
uv add sopsy

Quickstart

Retrieve a secret value:

from sopsy import Sops

sops = Sops("secrets.yml")

my_secret_key = sops.get("my_secret_key")
print(f"single secret: {my_secret_key}")

secrets = sops.decrypt()
print(f"all my secrets: {secrets}")

Encrypt a file:

import json
from pathlib import Path
from sopsy import Sops

plaintext_content = json.dumps({"hello": "world"})
Path("secrets.json").write_text(plaintext_content)

s = Sops("secrets.json", in_place=True)
# you either need a `.sops.yml` configuration file with `creation_rules` set
# or append some arguments to the `Sops.global_args` attribute:
# s.global_args.extend([
#     "--age", "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw"
# ])
s.encrypt()

API Reference

Check documentation.