A minimal Python library scaffold for codex-python
Project description
codex-python
A minimal Python library scaffold using uv with Python 3.13+.
Quickstart
- Requires Python 3.13+.
- Package import name:
codex. - Distribution name (PyPI):
codex-python.
Repo
- Git:
git@github.com:gersmann/codex-python.git - URL: https://github.com/gersmann/codex-python
Usage
Basic non-interactive execution via Codex CLI:
from codex import run_exec
out = run_exec("explain this repo")
print(out)
Options:
- Choose model:
run_exec("...", model="gpt-4.1") - Full auto:
run_exec("scaffold a cli", full_auto=True) - Run in another dir:
run_exec("...", cd="/path/to/project")
Streaming JSON events (no PyO3 required):
from codex.protocol.runtime import stream_exec_events
for event in stream_exec_events("explain this repo", full_auto=True):
# event is a dict with shape {"id": str, "msg": {...}}
print(event)
The event payload matches the Pydantic models in codex.protocol.types (e.g., EventMsg).
Using a client with defaults:
from codex import CodexClient
client = CodexClient(model="gpt-4.1", full_auto=True)
print(client.run("explain this repo"))
Install uv
- macOS (Homebrew):
brew install uv - Or via install script:
- Unix/macOS:
curl -LsSf https://astral.sh/uv/install.sh | sh - Windows (PowerShell):
iwr https://astral.sh/uv/install.ps1 -UseBasicParsing | iex
- Unix/macOS:
See: https://docs.astral.sh/uv/
Create a virtual env (optional)
uv python install 3.13
uv venv --python 3.13
. .venv/bin/activate # or .venv\Scripts\activate on Windows
Build
uv build
Artifacts appear in dist/ (.whl and .tar.gz).
Publish to PyPI
- Manual:
export PYPI_API_TOKEN="pypi-XXXX" # create at https://pypi.org/manage/account/token/
uv publish --token "$PYPI_API_TOKEN"
- GitHub Actions (Trusted Publishing): enable PyPI Trusted Publishing for
gersmann/codex-pythonand push a tag likev0.1.0. No token is needed. The workflow at.github/workflows/publish.ymlrequests an OIDC token and runsuv publish --trusted-publishing=alwaysonv*tags.
Dev tooling
- Lint:
make lint(ruff + mypy) - Tests:
make test(pytest) - Format:
make fmt(ruff formatter) - Pre-commit:
uvx pre-commit install && uvx pre-commit run --all-files
Protocol bindings (from codex-rs)
- Prereq: Rust toolchain (
cargo) installed. - Generate Python types from the upstream protocol with:
make gen-protocol
This will:
- run
codex-proj/codex-rs/protocol-tsto emit TypeScript types under.generated/ts/ - convert them to Python
TypedDict/Literalaliases atcodex/protocol/types.py
Project Layout
.
├── codex/ # package root (import name: codex)
│ └── __init__.py # version lives here
├── pyproject.toml # PEP 621 metadata, hatchling build backend
├── README.md
└── .gitignore
Versioning
Version is managed via codex/__init__.py and exposed as __version__. The build uses Hatch’s version source.
Python Compatibility
- Requires Python
>=3.13.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_python-0.1.2.tar.gz.
File metadata
- Download URL: codex_python-0.1.2.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fee860e4e8751d2bfc4c8360d40bfbae71c2a27b64548b8f683a3af6c83c9b1d
|
|
| MD5 |
de7bc8065486e50aa4691fbd6b7f82c2
|
|
| BLAKE2b-256 |
333010b05bb2ece7e842e61602e88fcb2c7312a8eb69f05bcdfc8677df4f1a7a
|
File details
Details for the file codex_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: codex_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56729c985b0cd523b2ea6883071d84c2128bab449d1de28a415e3c0b4e087b7
|
|
| MD5 |
8391ed7e7ff2fea8c94bb29460889dcf
|
|
| BLAKE2b-256 |
339d2387e78a608784e9a9b31157d6830b590734235988e81c646141dbfab6f8
|