Pyo3 library crate as dependency for binary crate

I have a pyo3 lib crate that works as expected, but in addition to the python API, I'm trying to right a command-line interface (CLI) that uses the clap crate. If I put the CLI crate in parallel with the pyo3 crate and add the core crate to my Cargo.toml file with a relative path, Cargo is happy, but when I add

extern crate core;
use core;

to the Cargo.toml of the CLI crate, the crate is not available. Is this an intrinsic pyo3 problem? Is it related to the fact that the pyo3 crate is a cdylib?

My current idea for a workaround is to make it so that the pyo3 stuff is conditionally compiled (or not compiled) and to write an attribute-style procedural macro that removes all the pyo3 attributes if pyo3 is not used. This seems quite tedious and painful so I'm hoping there will be a cleaner solution.

Why are you explicitly declaring core? That's usually not needed, it's imported automatically unless you are using #[no_core].

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.