rigetti / rigetti/rigetti-pyo3

`create_init_submodule!` should have some support for feature-gated items.

Open
#63 0 comments 0 reactions 1 assignee View on GitHub

@asaites is already working on this.

Since Jul 17, 2026.

Dominant language
Rust
Stars
11
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Currently, if you want to feature-gate items to add to a submodule, you can't use create_init_submodule. Arguably, it's confusing to have feature-gated items in a Python extension module, but regardless, it's something we see in the wild (e.g., in qcs-sdk-rust, some items are gated behind a libquil feature).

The work-around at the moment is to use multiple create_init_submodule blocks with appropriate cfg(not(feature = "...")) and cfg(feature = "...") attributes, but that's not great, and it's especially problematic if there are multiple features at play, since it requires an exponential number of blocks.

We don't necessarily need to support cfg attributes within the macro, but alternatively, we could have an "extension point" to specify an ordinary function to call during the module initialization process. Within it, we could just write out the gated items "the hard way".

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.