Change the package root for cargo publish

Is it possible to include the parent directory of the package root when publishing to crates.io ?

The reason is that I'm writing a FFI binding and the owner of that library would like to keep its structure, which is like:

lib
├── cpp-package
├── python-package
└── src

So, would it be possible to add rust-package but publish lib?

Yes you can do this by adding a [lib] section in your Cargo.toml:

[lib]
path = "rust-package/lib.rs"

First, thanks for your answer!
However, it seems I didn't express myself well enough.
The problem is that the Cargo.toml lies in rust-package and as far as I know this defines the package root.

lib
├── cpp-package
├── python-package
├── rust-package
│   └── Cargo.toml
└── src

So when publishing to crates.io usually only the content of rust-package is published but I'd like to include the content of its parent dir /lib too.

Ah I see, I'm not sure how you can do this without moving the Cargo.toml file. Pretty sure the Cargo.toml file must always be the at the root of the published package. What is the reason for wanting to include the other packages? Does the Rust package depend on them?

yes, in lib/src is the library located I'm writing the binding for.
It's not my preferred project structure but as I said, the project owner would like to keep it like that - which is likely not possible.
Maybe it would work if I add the repo itself as a submodule of itself but that would be a mean circular dependency...

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.