Reputation: 1
I have a pyo3 project lclPy
and as per the book of pyo3 this is part of the project structure.
lclPy/
├── src/
│ ├── io/
│ ├── local_search/
│ ├── problem/
│ ├── termination/
│ └── lib.rs
├── python/
│ └── lclpy/
│ ├──.../
│ ├──.../
│ └── __init__.py
└── Cargo.toml
this is the pyproject.toml:
[build-system]
requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"
[project]
name = "lclpy"
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"]
python-source = "python"
this is the cargo.toml:
[package]
name = "lclpy"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "lclpy"
crate-type = ["cdylib","rlib"]
[dependencies]
csv = "1.3.0"
pyo3 = { version = "0.21.2",features = ["extension-module"] }
rand = { version = "0.8.5", features = ["small_rng"] }
The problem is not that I need to use these functions/classes in the python folder. The problem is that i need these functions/classes to coexist with the python folder as python library. The rust is kind of a copy but better that's why both are present to be able to compare the two. All the rust code is pure rust without any pyo3 attributes. Only in the lib.rs are there wrapper classes for all the traits with methods to call the functions. But when the python folder is absent and i let Maturin build a rust only project everything compiles and works. but when the python folder is present it doesn't compile all rust code.
I've tried this version like on Maturin
my-rust-and-python-project
├── Cargo.toml
├── python
│ └── my_project
│ ├── __init__.py
│ └── bar.py
├── pyproject.toml
├── README.md
└── src
└── lib.rs
Upvotes: 0
Views: 86
Reputation: 1
For anyone searching for the answer
from lclpy import lclpy as lcl_rust
This may be stupid, but I'm sure somebody else new to this will find this helpful.
Upvotes: 0