Skip to content

Commit

Permalink
implement python bindings as pyraydeon
Browse files Browse the repository at this point in the history
Includes the ability to add custom geometry rendering implemented in
python.
  • Loading branch information
cbgbt committed Nov 19, 2024
1 parent 7d8f023 commit a5c5a16
Show file tree
Hide file tree
Showing 37 changed files with 8,451 additions and 145 deletions.
205 changes: 205 additions & 0 deletions .github/workflows/raydeon-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
name: raydeon-ci

on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
test-linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install perceptualdiff
run: sudo apt-get install -y perceptualdiff
- name: Install resvg
run: cargo install --locked resvg
- name: Run tests
run: make build

linux:
runs-on: ${{ matrix.platform.runner }}
needs: ["test-linux"]
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: "true"
manylinux: auto
working-directory: pyraydeon
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: pyraydeon/dist

musllinux:
runs-on: ${{ matrix.platform.runner }}
needs: ["test-linux"]
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: "true"
manylinux: musllinux_1_2
working-directory: pyraydeon
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: pyraydeon/dist

windows:
runs-on: ${{ matrix.platform.runner }}
needs: ["test-linux"]
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: "true"
working-directory: pyraydeon
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: pyraydeon/dist

macos:
runs-on: ${{ matrix.platform.runner }}
needs: ["test-linux"]
strategy:
matrix:
platform:
- runner: macos-13
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: "true"
working-directory: pyraydeon
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: pyraydeon/dist

sdist:
runs-on: ubuntu-latest
needs: ["test-linux"]
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: pyraydeon
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: pyraydeon/dist

# release:
# name: Release
# runs-on: ubuntu-latest
# if: ${{ startsWith(github.ref, 'refs/tags/pyraydeon-v') || github.event_name == 'workflow_dispatch' }}
# needs: [linux, musllinux, windows, macos, sdist, "test-linux"]
# permissions:
# # Use to sign the release artifacts
# id-token: write
# # Used to upload release artifacts
# contents: write
# # Used to generate artifact attestation
# attestations: write
# steps:
# - uses: actions/download-artifact@v4
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-path: "wheels-*/*"
# - name: Publish to PyPI
# if: "startsWith(github.ref, 'refs/tags/')"
# uses: PyO3/maturin-action@v1
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# with:
# command: upload
# args: --non-interactive --skip-existing wheels-*/*
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ Cargo.lock
build
target
*.svg
**.png
todo.md
dist/
.ruff_cache/
.pytest_cache/

27 changes: 15 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
[package]
name = "raydeon"
version = "0.1.0"
authors = ["cbgbt <cbgbt@cabbage.bot>"]
edition = "2018"
[workspace]
resolver = "2"
members = [
"raydeon",
"pyraydeon",
]

[dependencies]

[workspace.dependencies]
raydeon = { path = "./raydeon", version = "0.1" }
pyrayeon = { path = "./pyraydeon", version = "0.1" }

anyhow = "1"
cgmath = "0.17"
collision = "0.20"
env_logger = "0.11"
euclid = "0.22"
float-cmp = "0.5"
log = "0.4"
rayon = "1.2"
tracing = { version = "0.1", features = ["log"] }

[dev-dependencies]
anyhow = "1"
env_logger = "0.11"
float-cmp = "0.5"
svg = "0.18"
tracing = "0.1"
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.DEFAULT_GOAL := build

.PHONY: lint
lint:
cargo clippy --locked -- -D warnings --no-deps
uv --project pyraydeon run ruff check pyraydeon

.PHONY: check-fmt
check-fmt:
cargo fmt --check
uv --project pyraydeon run ruff format --check pyraydeon

.PHONY: render-test
render-test:
./raydeon/check-examples.sh
./pyraydeon/check-examples.sh

.PHONY: unit-test
unit-test:
cargo test --locked

.PHONY: check
check: check-fmt lint unit-test render-test

.PHONY: build
build: check
cargo build --locked
75 changes: 75 additions & 0 deletions pyraydeon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/target

# We don't lock deps
uv.lock

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
.venv/
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
include/
man/
venv/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-selfcheck.json

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

.DS_Store

# Sphinx documentation
docs/_build/

# PyCharm
.idea/

# VSCode
.vscode/

# Pyenv
.python-version
14 changes: 14 additions & 0 deletions pyraydeon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "pyraydeon"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "pyraydeon"
crate-type = ["cdylib"]

[dependencies]
raydeon.workspace = true

pyo3 = { version = "0.23", features = ["extension-module"] }
Loading

0 comments on commit a5c5a16

Please sign in to comment.