[英]pyo3 rust module kills Python on import
I'm writing my first Rust-based Python module, and it kills the Python process on import.我正在编写我的第一个基于 Rust 的 Python 模块,它会在导入时终止 Python 进程。 I've got it down to a pretty minimal example, based loosely on the html-py-ever example (which does run for me without crashing).
我已经把它归结为一个非常简单的例子,松散地基于html-py-ever 示例(它确实为我运行而不会崩溃)。
I'm running Python 3.8 on an M1 macbook, Python is compiled for arm64.我在 M1 macbook 上运行 Python 3.8,Python 是为 arm64 编译的。
% python -c "import platform;print(platform.machine())"
arm64
My output, reproducer command using the files pasted below.我的输出,使用下面粘贴的文件的复制器命令。 The install should take care of any python requirements:
安装应该处理任何 python 要求:
(rust) jeremytemp@Jeremy-McGibbons-MacBook-Pro minimal % pip install -e . && python test.py
Obtaining file:///Users/jeremytemp/rust/minimal
Installing collected packages: minimal
Attempting uninstall: minimal
Found existing installation: minimal 0.1.0
Uninstalling minimal-0.1.0:
Successfully uninstalled minimal-0.1.0
Running setup.py develop for minimal
Successfully installed minimal-0.1.0
zsh: killed python test.py
src/lib.rs: src/lib.rs:
use pyo3::{prelude::*, wrap_pyfunction};
#[pyfunction]
fn foo() -> PyResult<u64>{
let u: u64 = 1;
Ok(u)
}
#[pymodule]
fn minimal(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(foo, m)?)?;
Ok(())
}
Cargo.toml:货物.toml:
[package]
name = "minimal"
version = "0.1.0"
edition = "2021"
[dependencies]
pyo3 = { features = ["extension-module"] }
[lib]
name = "minimal"
crate-type = ["cdylib"]
setup.py:设置.py:
from setuptools import setup
from setuptools_rust import RustExtension
setup(
rust_extensions=[RustExtension("minimal.minimal")],
)
setup.cfg:设置.cfg:
[metadata]
name = minimal
version = 0.1.0
license = MIT
[options]
packages = minimal
zip_safe = False
setup_requires = setuptools-rust >= 0.12.1;
python_requires = >=3.8
include_package_data = True
minimal/__init__.py
: minimal/__init__.py
:
from .minimal import *
test.py:测试.py:
import minimal
pip freeze output is点冻结输出是
(rust) jeremytemp@Jeremy-McGibbons-MacBook-Pro minimal % pip freeze
attrs==21.4.0
beautifulsoup4==4.11.1
certifi==2021.10.8
iniconfig==1.1.1
# Editable Git install with no remote (minimal==0.1.0)
-e /Users/jeremytemp/rust/minimal
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.0.8
pytest==7.1.2
semantic-version==2.9.0
setuptools-rust==1.3.0
soupsieve==2.3.2.post1
tomli==2.0.1
typing_extensions==4.2.0
What am I doing wrong?我究竟做错了什么? Are there any steps I can take to get more helpful debugging output than "killed"?
我可以采取什么步骤来获得比“杀死”更有用的调试输出?
Not a very satisfying answer, but the example executes fine on my windows machine.不是一个非常令人满意的答案,但该示例在我的 Windows 机器上执行得很好。 I'm assuming this is an issue with pyo3 on M1 Macs.
我假设这是 M1 Mac 上 pyo3 的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.