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.2

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.2
File Size Uploaded Provenance Actions
kcm_workspace-0.2.2.tar.gz 16.3 kB With provenance Details for kcm_workspace-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 28.5 kB

Release files / kcm_workspace-0.2.2.tar.gz

Download URL kcm_workspace-0.2.2.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f87897f7dcd0e56cc55ce40db9d224d8b95ee3d4ccdfa219ca415d98c5c07cf4
BLAKE2b-256 checksum
How to use checksums
abbfe9aae9f56e950a55db9422a5b18fdc138d34dbdb1a411eb0eadd1f0d5fef
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.2-py3-none-any.whl

Download URL kcm_workspace-0.2.2-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
715b51170747cc6b5a163b2bf1c7d0734104ddaac38821ccd5b0f9482c70e5ea
BLAKE2b-256 checksum
How to use checksums
29b951af2c12bea3f3e6816644378ec28a47ad4deecc19302c5f70f0616bb38e
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.2

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.2.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