Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- 'docs/**'
- 'web/**'
- 'tools/sourcey-api/**'
- 'README.md'
- '.github/workflows/deploy-pages.yml'
push:
Expand All @@ -15,6 +16,7 @@ on:
paths:
- 'docs/**'
- 'web/**'
- 'tools/sourcey-api/**'
- 'README.md'
- '.github/workflows/deploy-pages.yml'
workflow_dispatch:
Expand All @@ -28,7 +30,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
# Full history + tags so the docs generator can resolve a release line
# Full history + tags so the Sourcey generator can resolve a release line
# via `git describe` (default shallow checkouts have neither).
fetch-depth: 0
fetch-tags: true
Expand All @@ -38,20 +40,20 @@ jobs:
with:
node-version: '22'
cache: npm
cache-dependency-path: docs/package-lock.json
cache-dependency-path: tools/sourcey-api/package-lock.json

- name: Install documentation dependencies
run: npm ci --prefix docs
- name: Install Sourcey documentation dependencies
run: npm ci --prefix tools/sourcey-api

- name: Build and verify Sourcey reference
run: npm run check --prefix docs
- name: Build and verify Sourcey native reference
run: npm run check --prefix tools/sourcey-api

- name: Assemble GitHub Pages site
run: |
mkdir -p _site
cp -r web/* _site/
mkdir -p _site/api
cp -r docs/dist/* _site/api/
cp -r tools/sourcey-api/dist/* _site/api/
touch _site/.nojekyll

- name: Deploy to gh-pages
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/publish-micropython-lib.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Publish pure-Python graphics to micropython-lib, MIP index, and TestPyPI (pydisplay-graphics).
# Native graphics-cmod wheels are published by publish-testpypi.yml on the same tag.
# Publish pure-Python pygraphics to micropython-lib, MIP index, and TestPyPI (pygraphics).
# Native pygraphics-cmod wheels are published by publish-testpypi.yml on the same tag.
#
# Release trigger: push tag vX.Y.Z (see scripts/publish_release_tag.sh).
#
Expand All @@ -20,11 +20,11 @@ on:
type: string
required: false
sync_sources:
description: Sync graphics into micropython-lib
description: Sync pygraphics into micropython-lib
type: boolean
default: true
upload_testpypi:
description: Upload pydisplay-graphics wheels to TestPyPI
description: Upload pygraphics wheels to TestPyPI
type: boolean
default: false
publish_mip_index:
Expand All @@ -47,7 +47,7 @@ concurrency:
jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'PyDevices/graphics'
if: github.repository == 'PyDevices/pygraphics'
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
VERSION="$(normalize "$TAG")"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing pydisplay-graphics / MIP release $VERSION"
echo "Publishing pygraphics / MIP release $VERSION"

- name: Verify publish secrets
env:
Expand All @@ -99,8 +99,8 @@ jobs:
fi
fi
if [[ ${#missing[@]} -gt 0 ]]; then
echo "::error::GitHub did not supply secrets to PyDevices/graphics: ${missing[*]}"
echo "Org Settings → Secrets → Actions → each secret → Repository access → include graphics."
echo "::error::GitHub did not supply secrets to PyDevices/pygraphics: ${missing[*]}"
echo "Org Settings → Secrets → Actions → each secret → Repository access → include pygraphics."
exit 1
fi

Expand All @@ -126,7 +126,7 @@ jobs:
git -C micropython-lib remote set-url origin \
"https://x-access-token:${{ secrets.MICROPYTHON_LIB_DEPLOY_TOKEN }}@github.com/PyDevices/micropython-lib.git"

- name: Sync graphics into micropython-lib
- name: Sync pygraphics into micropython-lib
if: github.event_name == 'push' || inputs.sync_sources == true
env:
MICROPYTHON_LIB_DIR: ${{ github.workspace }}/micropython-lib
Expand All @@ -136,7 +136,7 @@ jobs:
VERSION="${{ steps.version.outputs.version }}"
MSG="${{ inputs.commit_message }}"
if [[ -z "$MSG" ]]; then
MSG="graphics: Release v${VERSION} (${GITHUB_SHA::7})."
MSG="pygraphics: Release v${VERSION} (${GITHUB_SHA::7})."
fi
EXTRA=(--commit-message "$MSG" --push)
if [[ "${{ github.event_name }}" != "push" && "${{ inputs.upload_testpypi }}" != "true" ]]; then
Expand All @@ -149,7 +149,7 @@ jobs:
if: github.event_name == 'push' || inputs.publish_mip_index == true
env:
MICROPYTHON_LIB_DIR: ${{ github.workspace }}/micropython-lib
GRAPHICS_DIR: ${{ github.workspace }}
PYGRAPHICS_DIR: ${{ github.workspace }}
MICROPYTHON_DIR: /tmp/micropython
MIP_INDEX_OUTPUT: /tmp/mip-index
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/publish-testpypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Build graphics-cmod wheels (Linux + Windows + Android) with cibuildwheel and upload to TestPyPI.
# Build pygraphics-cmod wheels (Linux + Windows + Android) with cibuildwheel and upload to TestPyPI.
#
# Release trigger: push an annotated semver tag vX.Y.Z (see scripts/publish_release_tag.sh),
# or workflow_dispatch.
Expand All @@ -7,7 +7,7 @@
# TESTPYPI_API_TOKEN — TestPyPI API token (same as PyDevices/pydisplay)
#
# Install from TestPyPI (wheels are platform-specific):
# pip install -i https://test.pypi.org/simple/ graphics-cmod
# pip install -i https://test.pypi.org/simple/ pygraphics-cmod

name: Publish TestPyPI

Expand All @@ -28,7 +28,7 @@ permissions:
jobs:
prepare:
runs-on: ubuntu-latest
if: github.repository == 'PyDevices/graphics'
if: github.repository == 'PyDevices/pygraphics'
outputs:
version: ${{ steps.version.outputs.version }}
steps:
Expand Down Expand Up @@ -66,12 +66,12 @@ jobs:
fi

echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing graphics-cmod release $VERSION"
echo "Publishing pygraphics-cmod release $VERSION"

build-wheels:
needs: prepare
runs-on: ${{ matrix.os }}
if: github.repository == 'PyDevices/graphics'
if: github.repository == 'PyDevices/pygraphics'
strategy:
fail-fast: false
matrix:
Expand All @@ -96,7 +96,7 @@ jobs:
build-android-wheels:
needs: prepare
runs-on: ubuntu-latest
if: github.repository == 'PyDevices/graphics'
if: github.repository == 'PyDevices/pygraphics'
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
publish:
needs: [prepare, build-wheels, build-android-wheels]
runs-on: ubuntu-latest
if: github.repository == 'PyDevices/graphics'
if: github.repository == 'PyDevices/pygraphics'
steps:
- uses: actions/download-artifact@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ wheelhouse/
wheels/
# Local packaging stamp written by build/publish helpers (see AGENTS.md)
VERSION
docs/node_modules/
docs/dist/
tools/sourcey-api/node_modules/
tools/sourcey-api/dist/
site/
24 changes: 12 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# AGENTS.md — graphics
# AGENTS.md — pygraphics

Native and pure-Python **graphics** (`import graphics`) for MicroPython,
CircuitPython, and CPython. Prefer `graphics-cmod` on desktop/Android when
available; otherwise `pydisplay-graphics` / MIP `graphics`.
Native and pure-Python **pygraphics** (`import pygraphics`) for MicroPython,
CircuitPython, and CPython. Prefer `pygraphics-cmod` on desktop/Android when
available; otherwise `pygraphics` / MIP `pygraphics`.

## Layout

- Root: `micropython.mk`, `micropython.cmake`, `circuitpython.mk`, `setup.py`,
patch scripts — build glue stays here for `USER_C_MODULES` discovery
- `src/` — `.c` sources and shared headers (`gfx_*.h`, `font_8x*.h`,
`graphics_qstrdefs.h`)
- `lib/graphics/` — pure-Python package (same public API as the cmod)
`pygraphics_qstrdefs.h`)
- `lib/pygraphics/` — pure-Python package (same public API as the cmod)
- `tests/` — native smoke and parity scripts
- `tools/` — developer benchmarks / helpers (not maintainer publish scripts)
- No `.c` / `.h` at repo root
Expand All @@ -23,20 +23,20 @@ python3 -m venv .venv
echo 0.0.0 > VERSION
.venv/bin/pip install -e .
.venv/bin/python tests/test_area.py
.venv/bin/python tests/test_graphics.py
.venv/bin/python tests/test_pygraphics.py

# pure Python
PYTHONPATH=lib .venv/bin/python -c "import graphics; assert graphics.implementation() == 'graphics_python'"
PYTHONPATH=lib .venv/bin/python -c "import pygraphics; assert pygraphics.implementation() == 'pygraphics_python'"
```

## Publishing

One tag `vX.Y.Z` publishes:

1. **graphics-cmod** — `publish-testpypi.yml` (cibuildwheel)
2. **pydisplay-graphics** + MIP — `publish-micropython-lib.yml` (micropython-lib + TestPyPI + gh-pages)
1. **pygraphics-cmod** — `publish-testpypi.yml` (cibuildwheel)
2. **pygraphics** + MIP — `publish-micropython-lib.yml` (micropython-lib + TestPyPI + gh-pages)

See `docs/PUBLISHING.md`. Next shared version continues the `graphics-cmod` line
See `docs/PUBLISHING.md`. Next shared version continues the `pygraphics-cmod` line
(`v0.0.9` → `v0.0.10`).

## After C changes
Expand All @@ -45,4 +45,4 @@ Refresh pydisplay’s committed runtimes with `../build_pydisplay_runtimes.sh`
from the cmods workspace root when the usermod is linked into those interpreters.

Font C headers: `python3 scripts/sync_fonts.py` (source of truth is
`lib/graphics/_font_8x*.py`).
`lib/pygraphics/_font_8x*.py`).
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# graphics

Native and pure-Python **graphics** for MicroPython, CircuitPython, and CPython.
Import as `graphics`.
Import as `pygraphics`.

| Product | Pip / MIP | Role |
|---------|-----------|------|
| **graphics-cmod** | TestPyPI `graphics-cmod` | All-C extension (prefer on desktop/Android when available) |
| **pydisplay-graphics** | TestPyPI `pydisplay-graphics`, MIP `graphics` | Pure-Python package (same public API) |
| **pygraphics-cmod** | TestPyPI `pygraphics-cmod` | All-C extension (prefer on desktop/Android when available) |
| **pygraphics** | TestPyPI `pygraphics`, MIP `pygraphics` | Pure-Python package (same public API) |

One release tag `vX.Y.Z` publishes both products at that version.

Expand All @@ -18,7 +18,7 @@ One release tag `vX.Y.Z` publishes both products at that version.
pip install \
-i https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
graphics-cmod
pygraphics-cmod
```

### Pure Python (TestPyPI)
Expand All @@ -27,26 +27,26 @@ pip install \
pip install \
-i https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
pydisplay-graphics
pygraphics
```

### MicroPython (MIP)

```python
import mip
mip.install("graphics", index="https://PyDevices.github.io/micropython-lib/mip/PyDevices")
mip.install("pygraphics", index="https://PyDevices.github.io/micropython-lib/mip/PyDevices")
```

### Quick start

```python
import graphics
from graphics import FrameBuffer, RGB565
import pygraphics
from pygraphics import FrameBuffer, RGB565

fb = FrameBuffer(bytearray(160 * 128 * 2), 160, 128, RGB565)
fb.fill(0)
fb.fill_rect(10, 10, 40, 40, 0xF800)
print(graphics.implementation()) # native_cmod or graphics_python
print(pygraphics.implementation()) # native_cmod or pygraphics_python
```

## What you get
Expand All @@ -58,9 +58,9 @@ print(graphics.implementation()) # native_cmod or graphics_python

## Links

- [Source-linked API reference](https://pydevices.github.io/graphics/api/)
- [Source](https://github.com/PyDevices/graphics)
- [Issues](https://github.com/PyDevices/graphics/issues)
- [Source-linked API reference](https://pydevices.github.io/pygraphics/api/)
- [Source](https://github.com/PyDevices/pygraphics)
- [Issues](https://github.com/PyDevices/pygraphics/issues)
- Related: [pydisplay](https://github.com/PyDevices/pydisplay)

## License
Expand All @@ -77,7 +77,7 @@ MIT (framebuf algorithms derived from MicroPython `extmod/modframebuf.c`, Damien
graphics/
micropython.mk / micropython.cmake / circuitpython.mk / setup.py
src/ # C sources + headers (gfx_*.h, font_8x*.h, qstrs)
lib/graphics/ # pure-Python package (import graphics)
lib/pygraphics/ # pure-Python package (import pygraphics)
tests/ # native smoke / parity tests
tools/ # developer benchmarks / helpers
docs/ scripts/ web/
Expand All @@ -89,14 +89,14 @@ graphics/
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/python tests/test_area.py
.venv/bin/python tests/test_graphics.py
.venv/bin/python tests/test_pygraphics.py
.venv/bin/python tests/test_subclass.py
```

### Pure Python (no extension)

```bash
PYTHONPATH=lib python3 -c "import graphics; print(graphics.implementation())"
PYTHONPATH=lib python3 -c "import pygraphics; print(pygraphics.implementation())"
```

### MicroPython
Expand All @@ -121,6 +121,6 @@ cd ../../..

### pydisplay integration

When this cmod is installed or linked, `graphics.framebuf_backend()` reports
`native` and `graphics.implementation()` reports `native_cmod`. Otherwise the
pure-Python package reports `graphics_python`.
When this cmod is installed or linked, `pygraphics.framebuf_backend()` reports
`native` and `pygraphics.implementation()` reports `native_cmod`. Otherwise the
pure-Python package reports `pygraphics_python`.
Loading
Loading