PyO3 / PyO3/pyo3

Building a wheel on macOS when using a `PyClass` from different crate does not work

Open
#1,967 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

I have a crate in which I define a PyClass. This PyClass I want to use in a different crate from which I want to build a wheel using maturin. This works perfectly fine on linux. On macOS and Windows, however, it does not.

I've built a minimum "failing" version of my example here inluding the error log. What I found is that I can get it to work on macOS as long as

  1. the crate that defines the PyClass does not have a #[pymodule] function, and
  2. that the PyClass does not have a method attached (#[new] works).

I asked this here on the gitter and @mejrs mentioned that it works on Windows if ABI features are disabled.

Contributor guide

Open the contributing guide

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.

Research direction

Start with the linked minimal failing repository and its error log, reproducing the wheel build on macOS and Windows and comparing it with Linux. Investigate the reported effects of a #[pymodule] function, methods on the PyClass, and disabled ABI features; done means the cross-crate PyClass wheel builds successfully on the affected platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.