Closed pawamoy closed 3 months ago
Hi, welcome to ast pyo3 support. I usually built it with maturin, like maturin develop
for dev version.
I am not very familiar with this ecosystem. Is pyo3 projects usually expected to be built with pyproject-build
?
Thanks for your help!
Is pyo3 projects usually expected to be built with pyproject-build?
pyproject-build is a build frontend for Python projects. It reads pyproject.toml
and uses the specified build-system metadata to build sdists and wheels for Python projects. In your case, pyproject.toml
specifies maturin>=0.15,<0.16
as the build-backend, so pyproject-build uses maturin to build this project.
After your comment, I tried building with maturin develop
directly, and it worked. I thought removing the cap to 0.16 in the build-system metadata would fix it (latest is 1.5.1), but no. pyproject-build apparently runs the following command:
maturin pep517 build-wheel -i /tmp/build-env-3os4z0xe/bin/python --compatibility off
(/tmp/build-env-3os4z0xe/bin/python is a temporary virtualenv)
Full logs:
% pyproject-build
* Creating venv isolated environment...
* Installing packages in isolated environment... (maturin>=0.15)
* Getting build dependencies for sdist...
* Building sdist...
Running `maturin pep517 write-sdist --sdist-directory /media/data/dev/rustpython-parser/ast-pyo3/dist`
πΉ Building a mixed python/rust project
π Found pyo3 bindings
π Found CPython 3.11 at /tmp/build-env-wrgp8mbb/bin/python3
π‘ Using build options features from pyproject.toml
π¦ Built source distribution to /media/data/dev/rustpython-parser/ast-pyo3/dist/rustpython_ast-0.0.1.tar.gz
rustpython_ast-0.0.1.tar.gz
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (maturin>=0.15)
* Getting build dependencies for wheel...
* Building wheel...
Running `maturin pep517 build-wheel -i /tmp/build-env-3os4z0xe/bin/python --compatibility off`
error: failed to load manifest for workspace member `/tmp/build-via-sdist-f2sr0kj1/rustpython_ast-0.0.1/ast-pyo3`
Caused by:
failed to load manifest for dependency `rustpython-ast`
Caused by:
failed to load manifest for dependency `rustpython-literal`
Caused by:
failed to read `/tmp/build-via-sdist-f2sr0kj1/rustpython_ast-0.0.1/literal/Cargo.toml`
Caused by:
No such file or directory (os error 2)
π₯ maturin failed
Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
Caused by: `cargo metadata` exited with an error:
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/build-env-3os4z0xe/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
ERROR Backend subprocess exited when trying to invoke build_wheel
I'm not familiar with maturin so I don't know how to make maturin pep517 build-wheel
work like maturin develop
.
Weirdly enough if I use this command with maturin 1.5.1 directly, it works...
% maturin pep517 build-wheel --compatibility off
β οΈ Warning: You specified maturin >=0.15, <0.16 in pyproject.toml under `build-system.requires`, but the current maturin version is 1.5.1
πΉ Building a mixed python/rust project
π Found pyo3 bindings
π Found CPython 3.11 at /home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.11.5/bin/python3
π‘ Using build options features from pyproject.toml
Compiling rustpython-ast-pyo3 v0.0.1 (/media/data/dev/rustpython-parser/ast-pyo3)
Finished release [optimized] target(s) in 7.03s
π¦ Built wheel for CPython 3.11 to /media/data/dev/rustpython-parser/target/wheels/rustpython_ast-0.0.1-cp311-cp311-linux_x86_64.whl
/media/data/dev/rustpython-parser/target/wheels/rustpython_ast-0.0.1-cp311-cp311-linux_x86_64.whl
This crate now placed in https://github.com/RustPython/rustpython-ast-pyo3 This issue seems to be happened with parsers default bigint feature malachite. I fixed this issue in the new repository.
Thanks @youknowone, I'll try the new repository and report back :slightly_smiling_face:
Yay that worked! Thanks a lot!
I cloned the repository, entered the
ast-pyo3
directory, and ranpyproject-build
:Any hint on how to fix that :slightly_smiling_face:?
As to why I'm trying to build it, well, I'd like to try it in a project of mine to see how well it performs and how much work it would need to use it instead of Python's
ast
.Quick question by the way: it builds an Abstract Syntax Tree and not a Concrete Syntax Tree right?