Skip to content

Exclude files only useful for development from published crates#147

Merged
brettcannon merged 1 commit intobrettcannon:mainfrom
decathorpe:main
Sep 13, 2021
Merged

Exclude files only useful for development from published crates#147
brettcannon merged 1 commit intobrettcannon:mainfrom
decathorpe:main

Conversation

@decathorpe
Copy link
Copy Markdown
Contributor

@decathorpe decathorpe commented Sep 3, 2021

This came up while packaging py / python-launcher for Fedora Linux.

The crates published to crates.io contain a few files that look like they're only ever useful for upstream development or your release process, and so they can be excluded from published crates (making upload / download sizes smaller, etc.).

  • /changelog.d: changelog entry fragments, only used for your release process
  • /docs/readme/: readme file template, only used during development (?)
  • /release/: collection of python files / scripts to handle release process
  • /dodo.py: not sure what this is, but looks like it's used solely for release process purposes

This PR introduces an explicit list of files to be included in published crates:

  • Cargo.toml is always implicitly included
  • /src/, /tests/, (essential metadata and source code)
  • README.md and CHANGELOG.md (documentation that's useful for "end users")
  • shell completions
  • the control flow diagram referenced from the README.md file, and the manual page for py.1
  • the LICENSE file

This change has the nice benefit of making the compressed crate ~60% smaller (32 KB vs. 100 KB).

@brettcannon brettcannon self-assigned this Sep 8, 2021
@brettcannon
Copy link
Copy Markdown
Owner

@decathorpe Thanks for the PR! I just got back from vacation so I have a bit of a backlog to get through, but I will have a look at your PR at some point (and I suspect I will accept it in some form).

Do you mind adding a changelog entry about the change?

@decathorpe
Copy link
Copy Markdown
Contributor Author

Sure, I'll polish up the PR tomorrow. Thanks!

@hroncok
Copy link
Copy Markdown
Contributor

hroncok commented Sep 9, 2021

FWIW I think the PR description would be nice in the commit message directly, so it is preserved.

@brettcannon
Copy link
Copy Markdown
Owner

Documentation on include https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields (to make it easier when I review the PR).

And the dodo.py file is for https://pydoit.org/.

@brettcannon
Copy link
Copy Markdown
Owner

@decathorpe would using a build script (i.e. build.rs) and removing the generated files be more or less helpful to your packaging (thinking about this in #150 )? For instance, I could make man page generation be via build.rs but then that would require having pandoc installed to make the man page work.

My guess is it wouldn't be much of a win, but I thought I would double-check.

@decathorpe
Copy link
Copy Markdown
Contributor Author

Just including the files that are meant for "end users" is the easiest solution, I think. Any build script or sophisticated machinery is probably over-engineering a solution for a non-problem.

@brettcannon brettcannon added the skip Cargo.lock Don't require Cargo.lock be updated by the PR label Sep 10, 2021
Copy link
Copy Markdown
Owner

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor stuff and a question as to why some things were left in.

Comment thread Cargo.toml Outdated
Comment thread Cargo.toml
Comment thread Cargo.toml Outdated
@brettcannon brettcannon reopened this Sep 10, 2021
This came up while packaging py / python-launcher for Fedora Linux.

The crates published to crates.io contain a few files that look like they're
only ever useful for upstream development or your release process, and so they
can be excluded from published crates (making upload / download sizes smaller,
etc.).

- `/changelog.d`: changelog entry fragments, only used for your release process
- `/docs/readme/`: readme file template, only used during development (?)
- `/release/`: collection of python files / scripts to handle release process
- `/dodo.py`: not sure what this is, but looks like it's used solely for
release process purposes

This PR introduces an explicit list of files to be included in published
crates:

- `Cargo.toml` is always implicitly included
- `/src/`, `/tests/`, (essential metadata and source code)
- `README.md` and `CHANGELOG.md` (documentation that's useful for "end users")
- shell completions
- the control flow diagram referenced from the `README.md` file, and the
  manual page for `py.1`
- the LICENSE file

This change has the nice benefit of making the compressed crate ~60%
smaller (32 KB vs. 100 KB).
@brettcannon brettcannon merged commit 5e9cc9f into brettcannon:main Sep 13, 2021
@brettcannon
Copy link
Copy Markdown
Owner

Thanks for the patience with answering all of my questions!

@decathorpe
Copy link
Copy Markdown
Contributor Author

No problem, thanks for accepting my changes! :)

@brettcannon brettcannon added the impact-maintenance Maintenance of the code/project label Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact-maintenance Maintenance of the code/project skip Cargo.lock Don't require Cargo.lock be updated by the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants