Skip to content

examples/RustCrateMacroPyO3Only.jl: a PyO3-only crate bound with @rust_crate at a package's top level - #359

Merged
terasakisatoshi merged 3 commits into
mainfrom
examples/pyo3-only-rust-crate-macro
Sep 8, 2026
Merged

examples/RustCrateMacroPyO3Only.jl: a PyO3-only crate bound with @rust_crate at a package's top level#359
terasakisatoshi merged 3 commits into
mainfrom
examples/pyo3-only-rust-crate-macro

Conversation

@terasakisatoshi

Copy link
Copy Markdown
Member

A self-contained example package that binds a PyO3-only crate — no RustCall attribute, no juliacall_macros dependency — with a single @rust_crate ... submodule="Bindings" at the package's top level, so the bindings module is generated while the package is precompiled (#339, merged in #351) instead of being written to a file by a deps/build.jl as examples/SampleCratePyO3Only.jl does. The crate is identical in shape to that example's; only the front door differs, which is the point of having both.

  • examples/RustCrateMacroPyO3Only.jl/: Project.toml (RustCall only — no Libdl, the generated module reaches it through RustCall), src/RustCrateMacroPyO3Only.jl (@rust_crate joinpath(@__DIR__, "..", "deps", "macro_pyo3_only") submodule="Bindings" and re-exports), deps/macro_pyo3_only/ (an rlib crate with a mandatory pyo3 = { default-features = false, features = ["macros"] }, the shape most real PyO3 crates have; the wrapper links libpython), test/runtests.jl (37 tests: functions, a #[pyclass] with methods, Result/Option returns, and that the package is precompiled and its bindings live under the package, not Main), README (what the example shows, what it needs — a Python with a linkable libpython — and how it differs from the build.jl example).
  • .github/workflows/Examples.yml: the new package in the matrix.
  • examples/README.md, CHANGELOG.md: the example listed.

Verified locally on top of 11fa2bf: Pkg.test() of the example passes (37/37); the Examples workflow runs it on the three platforms.

Advances #339's documentation; no acceptance criterion of an open issue is claimed.

🤖 Generated with Claude Code

https://claude.ai/code/session_014iJ1dZ7KEebWDjdY7fhPbw

@terasakisatoshi

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T16:15:39.538305Z eb9674b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5163977f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/RustCrateMacroPyO3Only.jl/Project.toml Outdated
@terasakisatoshi terasakisatoshi mentioned this pull request Sep 8, 2026
…t_crate at a package's top level

A self-contained example package that binds a PyO3-only crate — no
RustCall attribute, no `juliacall_macros` dependency — with a single
`@rust_crate ... submodule="Bindings"` at the package's top level, so the
bindings module is generated while the package is precompiled (#339)
instead of written to a file by a `deps/build.jl` as
examples/SampleCratePyO3Only.jl does. Same crate shape, the other front
door.

- examples/RustCrateMacroPyO3Only.jl/: Project.toml (RustCall only, compat
  `RustCall = "0.3.1"` — the first release whose `@rust_crate` has
  `submodule=`; 0.3.0 would not define `Bindings`), src, an `rlib` crate
  with a mandatory pyo3 (the wrapper links libpython), 37 tests, README.
- .github/workflows/Examples.yml: the package in the matrix.
- examples/README.md: the example listed. Its CHANGELOG entry landed with
  the v0.3.1 release (#360), which had to precede this so the compat
  bound resolves against the checkout.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014iJ1dZ7KEebWDjdY7fhPbw
@terasakisatoshi
terasakisatoshi force-pushed the examples/pyo3-only-rust-crate-macro branch from a516397 to b402fb5 Compare September 8, 2026 16:05
@terasakisatoshi

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b402fb5655

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/RustCrateMacroPyO3Only.jl/deps/macro_pyo3_only/src/lib.rs Outdated
…view)

i32::MIN / -1 panics in Rust even in release builds, so checked_div bypassed its PyResult error path and safe_div surfaced a RuntimeError instead of the documented DivideError. The crate uses i32::checked_div now (zero -> PyZeroDivisionError, overflow -> PyOverflowError); tests cover both the raw Err and the Julia-side DivideError for typemin(Int32) ÷ -1; README and the safe_div docstring say so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_014iJ1dZ7KEebWDjdY7fhPbw
@terasakisatoshi

Copy link
Copy Markdown
Member Author

@codex review

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_014iJ1dZ7KEebWDjdY7fhPbw
@terasakisatoshi

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: eb9674bf3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@terasakisatoshi
terasakisatoshi merged commit 1a06ad7 into main Sep 8, 2026
30 checks passed
@terasakisatoshi
terasakisatoshi deleted the examples/pyo3-only-rust-crate-macro branch September 8, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant