-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement python bindings as pyraydeon
Includes the ability to add custom geometry rendering implemented in python.
- Loading branch information
Showing
30 changed files
with
1,215 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
# This file is autogenerated by maturin v1.7.4 | ||
# To update, run | ||
# | ||
# maturin generate-ci github | ||
# | ||
name: pyraydeon-build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
tags: | ||
- "*" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
defaults: | ||
run: | ||
working-directory: pyraydeon | ||
|
||
jobs: | ||
linux: | ||
runs-on: ${{ matrix.platform.runner }} | ||
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 }} | ||
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 }} | ||
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 }} | ||
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 | ||
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] | ||
# 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-*/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ Cargo.lock | |
build | ||
target | ||
*.svg | ||
todo.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
[package] | ||
name = "raydeon" | ||
version = "0.1.0" | ||
authors = ["cbgbt <[email protected]>"] | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/target | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[build-system] | ||
requires = ["maturin>=1.7,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "pyraydeon" | ||
requires-python = ">=3.9" | ||
classifiers = [ | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dynamic = ["version"] | ||
[tool.maturin] | ||
features = ["pyo3/extension-module"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use pyo3::prelude::*; | ||
|
||
macro_rules! pywrap { | ||
($name:ident, $wraps:ty) => { | ||
#[derive(Debug, Clone)] | ||
#[pyclass(frozen)] | ||
pub(crate) struct $name(pub(crate) $wraps); | ||
|
||
impl ::std::ops::Deref for $name { | ||
type Target = $wraps; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl From<$wraps> for $name { | ||
fn from(value: $wraps) -> Self { | ||
Self(value) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
mod linear; | ||
mod ray; | ||
mod scene; | ||
mod shapes; | ||
|
||
/// A Python module implemented in Rust. | ||
#[pymodule] | ||
fn pyraydeon(m: &Bound<'_, PyModule>) -> PyResult<()> { | ||
crate::linear::register(m)?; | ||
crate::shapes::register(m)?; | ||
crate::scene::register(m)?; | ||
crate::ray::register(m)?; | ||
Ok(()) | ||
} |
Oops, something went wrong.