maturin 在我的 Mac 上构建成功,但在 CentOS6 上出错,如何修复?

问题描述 投票:0回答:1

Rust 项目(PyO3)在我的 Mac 上成功构建,但在 CentOS6 上出错。

货物.toml

[package]
name = "pyutils"
version = "0.1.0"
edition = "2021"

[lib]
name = "pyutils"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.20.0"

pyproject.toml

[build-system]
requires = ["maturin>=1.7,<2.0"]
build-backend = "maturin"

[project]
name = "pyutils"
requires-python = ">=3.8"
classifiers = [
    "Programming Language :: Rust",
    "Programming Language :: Python :: Implementation :: CPython",
    "Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]
[tool.maturin]
features = ["pyo3/extension-module"]
Linux 信息:
CentOS release 6.10 (Final)

Linux version 3.10.0.514.26.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #4 SMP Wed Aug 16 17:09:53 CST 2017

Linux 3.10.0.514.26.2.el7.x86_64 #4 SMP Wed Aug 16 17:09:53 CST 2017 x86_64 x86_64 x86_64 GNU/Linux
构建错误信息:
(py311) \[bae@test pyutils-rs\]$ maturin build -i python3.11

🔗 Found pyo3 bindings

🐍 Found CPython 3.11 at /home/bae/anaconda3/envs/py311/bin/python3.11

📡 Using build options features from pyproject.toml

Compiling target-lexicon v0.12.16

Compiling ...

Compiling pyo3-ffi v0.20.3

Compiling pyo3 v0.20.3

Compiling pyo3-macros-backend v0.20.3

Compiling pyo3-macros v0.20.3

error\[E0463\]: can't find crate for `pyo3_macros`

\--\> /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/prelude.rs:20:9
|

20 | pub use pyo3_macros::{pyclass, pyfunction, pymethods, pymodule, FromPyObject};

|         ^^^^^^^^^^^ can't find crate


error\[E0463\]: can't find crate for `pyo3_macros`

\--\> /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/lib.rs:444:9

|

444 | pub use pyo3_macros::{pyfunction, pymethods, pymodule, FromPyObject};

|         ^^^^^^^^^^^ can't find crate


error\[E0463\]: can't find crate for `pyo3_macros`

\--\> /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/lib.rs:455:9

|

455 | pub use pyo3_macros::pyclass;

|         ^^^^^^^^^^^ can't find crate


error\[E0463\]: can't find crate for `indoc`

\--\> /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/lib.rs:385:5

|

385 |     indoc,    // Re-exported for py_run

|     ^^^^^ can't find crate


error\[E0432\]: unresolved imports `crate::FromPyObject`, `crate::FromPyObject`,
`crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`, `crate::FromPyObject`

\--\> /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/buffer.rs:21:50
|

21 | use crate::{err, exceptions::PyBufferError, ffi, FromPyObject, PyAny, PyResult, Python};

|                                                  ^^^^^^^^^^^^

|

::: /home/bae/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/pyo3-0.20.3/src/conversions/std/array.rs:4:10

|

4  |     ffi, FromPyObject, IntoPy, Py, PyAny, PyDowncastError, PyObject, PyResult, Python, ToPyObject,

|          ^^^^^^^^^^^^


Some errors have detailed explanations: E0432, E0463.

For more information about an error, try `rustc --explain E0432`.

error: could not compile `pyo3` (lib) due to 5 previous errors

💥 maturin failed

Caused by: Failed to build a native library through cargo

Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/home/bae/anaconda3/envs/py311/bin/python3.11" PYTHON_SYS_EXECUTABLE="/home/bae/anaconda3/envs/py311/bin/python3.11" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/bae/rust/baidu/personal-code/pyutils-rs/Cargo.toml" "--lib"`

我刚刚创建了一个新项目使用

maturin new pyutils
,在CentOS6上也构建失败,在我的Mac上成功

rust pyo3 maturin
1个回答
0
投票

看起来像链接器错误。

(gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) )

这已经很老了。

我至少会更新

gcc
,但如果你不偏袒,
clang
有更好的支持。

https://support.aklwebhost.com/knowledgebase/how-to-install-llvm-and-clang-on-centos-6/

© www.soinside.com 2019 - 2024. All rights reserved.