I'm trying to get PyO3 working on my Mac M1 mini. If I follow the steps to get started with PyO3:
$ mkdir string_sum
$ cd string_sum
$ python -m venv .env
$ source .env/bin/activate
$ pip install maturin
I get "rustc...is not installed or not in PATH":
> maturin init
✔ What kind of bindings to use? · pyo3
✨ Done! Initialized project /Users/tweedle/projects/string_sum
> maturin develop
maturin failed
Caused by: rustc, the rust compiler, is not installed or not in PATH. This package requires Rust and Cargo to compile extensions. Install it through the system's package manager or via https://rustup.rs/.
I see this error come up a lot in the PyO3 issues, but it's generally solved by installing rustup. But I have rustup installed and on path:
❯ rustc --version
rustc 1.58.1 (db9d1b20b 2022-01-20)
> rustup which rustc
/Users/tweedle/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc
> export PATH="$PATH:~/.rustup/toolchains/stable-aarch64-apple-darwin/bin:~/.cargo/bin"
> maturin develop
maturin failed
Caused by: rustc, the rust compiler, is not installed or not in PATH. This package requires Rust and Cargo to compile extensions. Install it through the system's package manager or via https://rustup.rs/.
(Added to PATH again just to make sure.) I've also tried the x86 toolchain, same results. Cargo build also runs fine on the maturin-generated string_sum
rust code:
> cargo build
Updating crates.io index
Compiling proc-macro2 v1.0.36
Compiling unicode-xid v0.2.2
Compiling pyo3-build-config v0.15.1
Compiling syn v1.0.86
Compiling proc-macro-hack v0.5.19
Compiling once_cell v1.9.0
Compiling libc v0.2.116
Compiling cfg-if v1.0.0
Compiling parking_lot_core v0.8.5
Compiling scopeguard v1.1.0
Compiling smallvec v1.8.0
Compiling unindent v0.1.7
Compiling instant v0.1.12
Compiling lock_api v0.4.6
Compiling quote v1.0.15
Compiling parking_lot v0.11.2
Compiling pyo3 v0.15.1
Compiling paste-impl v0.1.18
Compiling paste v0.1.18
Compiling pyo3-macros-backend v0.15.1
Compiling indoc-impl v0.3.6
Compiling indoc v0.3.6
Compiling pyo3-macros v0.15.1
Compiling string_sum v0.1.0 (/Users/tweedle/projects/string_sum)
Finished dev [unoptimized + debuginfo] target(s) in 9.73s
Is it something weird with my M1 setup, my homebrew setup, my rust setup, my python setup, or something else I missed?
More info:
> neofetch
'c. tweedle@mini.local
,xNMM. ------------------
.OMMMMo OS: macOS 12.2 21D49 arm64
OMMM0, Host: Macmini9,1
.;loddo:' loolloddol;. Kernel: 21.3.0
cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 1 day, 2 hours, 12 mins
.KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 116 (brew)
XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: bash 5.1.16
;MMMMMMMMMMMMMMMMMMMMMMMM: Resolution: 1920x1080
:MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Rectangle
kMMMMMMMMMMMMMMMMMMMMMMMMWd. Terminal: kitty
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk CPU: Apple M1
.XMMMMMMMMMMMMMMMMMMMMMMMMK. GPU: Apple M1
kMMMMMMMMMMMMMMMMMMMMMMd Memory: 1975MiB / 16384MiB
;KMMMMMMMWXXWMMMMMMMk.
.cooc,. .,coo:.
> rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.58.1 (db9d1b20b 2022-01-20)`
> rustc --version
rustc 1.58.1 (db9d1b20b 2022-01-20)
> python --version
Python 3.9.10
> maturin --version
maturin 0.12.6
I've also tried using setuptools-rust
to similar effect, both calling setup.py directly and also using pip install .
.