cargo-dist icon indicating copy to clipboard operation
cargo-dist copied to clipboard

Request for a way to override the package name

Open ChanTsune opened this issue 1 year ago • 6 comments

At present, it appears that cargo-dist does not provide a way to override the package.name property in Cargo.toml.

Here's one idea for implementing this:

[workspace.metadata.dist.override]
name = "..."

I think this method could also be applied to properties other than name.

ChanTsune avatar Mar 06 '24 12:03 ChanTsune

Could you elaborate on what reason you need this for, so that I know what you do/don't want this to affect?

(Note that Cargo already lets you call your binaries something that isn't the package name: https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries)

Gankra avatar Mar 07 '24 19:03 Gankra

I guess that the current cargo-edit uses package.name in Cargo.toml as the name of the archive. For example, if package.name = "foo", the name of the archive would be something like foo-x86_64-apple-darwin.tar.xz. I need this feature because I want it to be named something else, like bar-cli-x86_64-apple-darwin.tar.xz.

ChanTsune avatar Mar 08 '24 14:03 ChanTsune

👋 hey @ChanTsune - i wonder if this is something you want because you have a project that has both a library and a cli? we don't currently have a feature to rename the package (so this is a feature request)- however, we do often run into people who have a single crate that is both a lib and a bin. in these cases, we often recommend to people that they change the project into a workspace with 2 crates (as it makes lots of things, including package naming better). is this the situation you are in?

ashleygwilliams avatar Mar 08 '24 19:03 ashleygwilliams

Hi @ashleygwilliams

My situation is that the name I originally wanted to use for my project was duplicated with a crate owned by someone else, so I cannot use it, and I had no choice but to give it another name. Specifically, this. I wanted to use the simple name "slice" but the name overlaps with the name of a crate owned by someone else, so I named the crate "slice-command". I want to be able to name the artifact in the GitHub release as I want it to be, so I want to change for the archive name.

So it is good if there is a way to change the archive name. The first notation I showed was because I thought it could be expressed in a unified notation when there were cases where who wanted to change properties like descriptions, author, etc. from the original. For example, who want a different description for crate and wix/main.wxs.

ChanTsune avatar Mar 09 '24 03:03 ChanTsune

Chiming in with a +1 on this. I think our use case sounds similar to @ChanTsune, specifically we wish to build releases for a forked project, and we want to stay up-to-date with our upstream.

Currently cargo dist uses <upstream name> everywhere and we want it to use <fork name> for releases. We can rename the crate, binary and references to it to <fork name> and then cargo dist will do the right thing. However these changes end up being quite pervasive and make it more difficult for us to stay in sync with upstream.

It would be great if we could use cargo dist config only to apply the required renames to the built artifacts rather than the code itself.

If it helps understand the use case, our project is https://github.com/verus-lang/verus-analyzer and the upstream is rust-analyzer.

Thanks for your work on cargo dist, it's much appreciated!

mmcloughlin avatar Jun 26 '24 19:06 mmcloughlin