Skip to content

Add Python wrapper proof-of-concept (TestPyPI) for #82 - #98

Open
stephenredhat wants to merge 2 commits into
chaoss:mainfrom
stephenredhat:python-wrapper-poc
Open

Add Python wrapper proof-of-concept (TestPyPI) for #82#98
stephenredhat wants to merge 2 commits into
chaoss:mainfrom
stephenredhat:python-wrapper-poc

Conversation

@stephenredhat

@stephenredhat stephenredhat commented Aug 26, 2026

Copy link
Copy Markdown

Description

Adds a small, stdlib-only Python wrapper for the disclosure CLI under a new python/ dir, so it's installable via pip/uvx and importable from notebooks. Per @andrew's suggestion it distributes the prebuilt binary (downloads on first use, verifies against checksums.txt, caches, shells out) rather than building an FFI binding. Provides a CLI passthrough (disclosure scan ...) and a small library API (scan()/text()/version() return parsed JSON). No changes to the Go tool. Intended for TestPyPI first.

This PR fixes #82

Notes for Reviewers

  • Deliberately a PoC — alpha, stdlib-only, one universal wheel; wrapped binary version pinned via DISCLOSURE_VERSION.
  • Treats CLI exit code 1 (AI detected) as success; only ≥2 raises. Covered by a test.
  • Open questions: python/ here vs a separate repo? license -only vs -or-later? PyPI name disclosure vs disclosure-cli?
  • Tested: go build/go test pass unchanged; pytest (6) passes; verified end-to-end against a local v1.0.0 binary.

Signed commits

  • Yes, I signed my commits.

Generative AI disclosure

  • This contribution was assisted or created by Generative AI tools.
    • Tools: Claude (Claude Code).
    • How: Code review, drafting the wrapper, checking it against the CLI source, fixing the exit-code handling, and writing tests.
    • Reviewed before submitting? Yes, reviewed the diff and ran the Go and Python test suites.

Adds a small, stdlib-only Python package under python/ that makes the
disclosure CLI usable from Python (pip install / uvx and an importable
library API). It downloads the prebuilt release binary, verifies it
against checksums.txt, caches it, and shells out to it -- no FFI, per
the approach recommended on the issue.

Exit code 1 (AI detected) is treated as a successful result; only
exit code >= 2 raises. Covered by tests in python/tests.

No changes to the Go tool or its layout. Intended for TestPyPI first.

Fixes chaoss#82

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Stephen Oresanya <soresany@redhat.com>
Comment thread python/src/disclosure/__main__.py
Comment thread python/src/disclosure/_binary.py Outdated
Comment thread python/pyproject.toml
@omkar-foss

omkar-foss commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

@stephenredhat regarding your open questions above:

Open questions: python/ here vs a separate repo? license -only vs -or-later? PyPI name disclosure vs disclosure-cli?

I think the separate python/ folder in this repo with all the wrapper code (like in this PR) is good enough. For license, I'd prefer if we keep -or-later since it's more future-compatible than -only. Regarding PyPI name, can we name it disclosure-py? So we follow standard python wrapper naming conventions :)

- __main__: return exit code 2 (not 1, "AI detected") on resolution failure
- _binary: fail closed when checksum is unavailable or missing; verify before caching
- packaging: bundle LICENSE in wheel and sdist
- add tests for the exit-code and checksum failure paths

Signed-off-by: Stephen Oresanya <soresany@redhat.com>
@stephenredhat

Copy link
Copy Markdown
Author

Thanks @andrew , fixed all three in the latest commit

@stephenredhat

Copy link
Copy Markdown
Author

@omkar-foss Thanks, Ill keep it in the python folder and name it disclosure-py. On the license I've matched what the repo already use for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Anyone experienced at making python wrappers of golang things?

3 participants