Skip to main content

kcm-workspace

Classe base para os scripts de workspace baseados em docker compose (clone, setup, launch, shell, manage, git e outros).

Cada projeto tem, em <projeto>/workspace/<projeto>, um script que estende Workspace e informa no construtor o que é específico dele.

Uso

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = ["kcm-workspace>=0.2.0"]
# ///
from kcm_workspace import GitClone, Workspace

GITBASE = "git@github.com:minha-org"


class Projeto(Workspace):
    def __init__(self):
        super().__init__(
            __file__,
            git_clones=[
                GitClone("app", f"{GITBASE}/app.git"),
                GitClone("lib", f"{GITBASE}/lib.git", "dev"),
            ],
            mk_volumes=["db"],
            hosts=("PROJETO", "127.0.0.1    projeto.local"),
            cli_dict={"db": "psql"},
            shell_dict={"db": "sh"},
        )

    def collectstatic(self) -> int:
        """Coleta os estáticos. Aplica-se a: $services_names$"""
        return self._execute("docker compose exec web python manage.py collectstatic")


if __name__ == "__main__":
    Projeto.main()
  • GitClone.folder relativo é resolvido a partir da pasta do projeto (pai de workspace).
  • GitClone.branch vazio clona a branch padrão do remoto.
  • Após clonar, roda pre-commit install nos repositórios com .pre-commit-config.yaml.
  • hosts=(nome, linha) adiciona a linha ao arquivo de hosts no setup.
  • compress_plugins grava em plugins_build_dir (relativo ao projeto; padrão workspace/build/plugins) com o nome plugin_package_name (padrão {plugin}-{version}.zip).
  • Um método vira comando quando a docstring termina com Aplica-se a: <escopos>.
  • Comandos desconhecidos são repassados para docker compose.
  • No Windows, use um wrapper <projeto>.ps1:
$nomeSemExtensao = (Get-Item $PSCommandPath).BaseName
uv run --script "$PSScriptRoot\$nomeSemExtensao" @args

Atributos disponíveis

project_name, project_dir, workspace_dir, volumes_dir, home, argv, git_clones, mk_volumes, moodle_plugins, cli_dict, shell_dict, hosts, plugins_build_dir, plugin_package_name.

Métodos auxiliares

_execute(cmd, *args), _service_is_running(svc), _service_is_healthy(svc), _prefixed_envs(prefix), _resolve_django_service_and_args(), _verb.

Desenvolvimento

uv pip install -e ".[dev]"
pytest --cov=kcm_workspace

Metadata

Release files for kcm-workspace 0.2.1

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

Source distribution (sdist)

Source distribution for kcm-workspace 0.2.1
File Size Uploaded Provenance Actions
kcm_workspace-0.2.1.tar.gz 15.8 kB With provenance Details for kcm_workspace-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kcm-workspace 0.2.1
File Interpreter ABI Platform Actions
kcm_workspace-0.2.1-py3-none-any.whl Python 3 none any Details for kcm_workspace-0.2.1-py3-none-any.whl

Total release size: 27.7 kB

Release files / kcm_workspace-0.2.1.tar.gz

Download URL kcm_workspace-0.2.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cb5ecf3264c741401a57ce55f60d193caa02b622efb8baafca3f7a393b6a96fe
BLAKE2b-256 checksum
How to use checksums
0b9ef5956b300c678a492742f24abb71f0f8b8715d277614beb86fd986fda572
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / kcm_workspace-0.2.1-py3-none-any.whl

Download URL kcm_workspace-0.2.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f6af8fdc49758ca046e5eebaafc945dd910dfda9fd2e9bed0bf09a862cce26d
BLAKE2b-256 checksum
How to use checksums
52e10a62ee02135fc371fa668f7a1a2743b22284f5159c6e2d41e8b8905b03d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for kcm-workspace 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kcm_workspace-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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.

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