Closed DanielChaseButterfield closed 1 year ago
Have you tried maturin 1.0 yet? No bugfixes will be backported to the old 0.13 versions.
I didn't know maturin 1.0 existed! I've now updated, and I can now see my phython functions and classes. However, now I can't see my Rust functions. This is what print(dir(actag)) returns now:
['AcTag', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'actag_src', 'adaptive_threshold', 'contour_identification', 'median_filter', 'quad_fitting', 'sonar_parameters', 'tag_decoding', 'tag_parameters']
Am I correct in assuming that both the python and rust functions should be available?
No, Rust functions/classes are contained in actag
(the name of your Rust extension module) module, you can re-export it to top level module if you want.
Please refer to https://www.maturin.rs/project_layout.html#mixed-rustpython-project for more information.
Okay, thank you! I got it working by adding this to the init.py file:
import actag as actag_rust
Bug Description
This may seem like a duplicate of #885, but that uses a different version of Maturin, and the solution for that thread is not the solution for my issue. I am trying to build into a conda virtual environment in WSL, and my pip wheel that is created by running
maturin develop
does not have any of my python functions or classes in it, just the functions defined by the Rust module. I have a mixed Python/Rust project with the following structure:My pyproject.toml contains:
My Cargo.toml contains:
My init.py file contains:
My actag_src.py file contains an AcTag class. It also imports the
actag
module generated by the Rust side of the code.With this setup, I can successfully build the pip wheel and install it with
maturin develop
, but I get the following error when I try to use the AcTag class from the python code:However, I can see all of the Rust functions when I run
print(dir(actag))
:Your maturin version (
maturin --version
)0.13.0
Your Python version (
python -V
)3.9.16
Your pip version (
pip -V
)23.0.1
What bindings you're using
pyo3
Does
cargo build
work?If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash
/
)?Steps to Reproduce
conda create -n tester python=3.9
conda activate tester
pip install maturin
maturin develop --release
from the main directory of the repository.detector = actag.AcTag(min_range=0.1, max_range=1.5, horizontal_aperture=1.0472, tag_family="AcTag24h10", tag_size=0.130628571428644, median_filter_kernel_radius=4, adaptive_threshold_kernel_radius=8, adaptive_threshold_offset=1, quads_use_same_random_vals=True)