Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider including xtask/ in the published crates #654

Closed
musicinmybrain opened this issue Nov 30, 2024 · 7 comments
Closed

Consider including xtask/ in the published crates #654

musicinmybrain opened this issue Nov 30, 2024 · 7 comments

Comments

@musicinmybrain
Copy link
Contributor

In Fedora Linux, we have the following rule:

Projects from crates.io MUST be packaged from the sources that are published there

This has been working well for packaging both the library and the command-line tool, but since #645 (which I agree was a good idea overall), the published crates no longer contain everything necessary to generate the man pages because xtask/* was explicitly excluded.

I can work around this by adding the GitHub source archive as an additional source, which is a bit tedious but workable. However, this is made more difficult by the fact that some of the test files, like issue-141.png, have dubious license/copyright status. By looking at their contents, it is reasonable to suspect they are not covered by oxipng’s MIT license, and indeed to suspect that they may not be redistributable at all. Therefore, I would need to use a script to produce a filtered version of the GitHub source archive for Fedora to use and distribute in source RPMs. This, too, is precedented and possible, but it’s becoming a lot of work to do for a man page!

Would you consider just removing the line

"xtask/*",

from package.exclude in Cargo.toml? This would add only three tiny files to the published crates, in exchange for avoiding all of the above packaging issues.

@andrews05
Copy link
Collaborator

Apologies for the trouble, it sounds like a pretty reasonable request. I’ll let @AlexTMjugador pick it up though as I’m not sure if there was a reason for excluding that.

@AlexTMjugador
Copy link
Collaborator

I chose to explicitly exclude the xtask files because I believed they weren't necessary for crate consumers, and by leaving them out, I achieved two benefits: enforcing the intended implementation detail encapsulation, and slightly reducing the size of the published crate, both of which seemed like a win-win to me.

However, my rationale above did not consider that Linux distributions might actually find these artifacts useful for their packaging needs. Therefore, I too think this is a reasonable request we can apply; there was no reason to exclude these files other than that being "technically neater" in the sense stated above.

@AlexTMjugador
Copy link
Collaborator

AlexTMjugador commented Dec 2, 2024

I've explored several Cargo manifest exclude/include combinations to implement this, but unfortunately, it seems that including the xtask subcrate within the oxipng crate isn't possible due to how cargo publish works.

It'd be technically possible to rename the xtask Cargo.toml manifest to something else so that we're not hit by that limitation, but then that file would need to be renamed back to its original name before that xtask is used. Would that be a good tradeoff for the purposes of packaging?

@musicinmybrain
Copy link
Contributor Author

I've explored several Cargo manifest exclude/include combinations to implement this, but unfortunately, it seems that including the xtask subcrate within the oxipng crate isn't possible due to how cargo publish works.

Hmm, that’s unfortunate. I didn’t realize that was the case when I opened this issue.

It'd be technically possible to rename the xtask Cargo.toml manifest to something else so that we're not hit by that limitation, but then that file would need to be renamed back to its original name before that xtask is used. Would that be a good tradeoff for the purposes of packaging?

I think that sounds rather awkward and confusing. I would rather not encourage you to commit a “weird” workaround. I can live with needing an auxiliary source archive from GitHub to build the man page, especially since #655 has been dealt with.

@musicinmybrain
Copy link
Contributor Author

I was just talking about this with @decathorpe, who pointed out that another possible approach would have been to keep building the man page in build.rs, but gate the man page generation and the associated dependencies on a feature flag. I don’t want to push for more churn in the implementation, though. As I said, though, I can live with the auxiliary source, and using an auxiliary source has the advantage that I should be able to copy in tests/ and run them, too.

@AlexTMjugador
Copy link
Collaborator

AlexTMjugador commented Dec 2, 2024

Adding a "private" feature for manpage generation could work, but Cargo features can't truly be private: they can appear in the documentation and can be enabled by any crate that depends on oxipng. Even though in practice naming such a feature in a way that clearly indicates it's not part of the public interface works well enough (and there is a convention for considering features beginning with underscores as private), if you feel that the auxiliary source approach is cleaner overall and not too complicated to implement, let's go with that! 👍

It would also have the added benefit you stated of including the tests folder, which has always been excluded from the published crate due to its large size.

@musicinmybrain
Copy link
Contributor Author

I’m closing this based on the above discussion. Thanks for investigating!

@musicinmybrain musicinmybrain closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants