build: include bash and zsh completions in wheels #4048
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2993
This builds shell completions files for BASH and ZSH via
shtab
, which unlike other tools I've looked up in the past can parse anargparse.ArgumentParser
object:https://github.com/iterative/shtab
It's also only a simple build step and no runtime dependencies are required for implementing shell completions, which is the ideal solution.
Unfortunately, it currently does only support BASH and ZSH. I would love to see FISH support in the future as well.
The shell completion files get built via
./script/build-shell-completions.sh
and are optional in thedata_files
field insetup.py
, just like the man pages.This means the wheels will include these files when built prior to running setup.py, and pip will write them to
${XDG_DATA_HOME:-${HOME}/.local/share}/bash-completion/completions/streamlink
${XDG_DATA_HOME:-${HOME}/.local/share}/zsh/site-functions/_streamlink
or (if run as sudo - which shouldn't be done)
/usr/share/bash-completion/completions/streamlink
/usr/share/zsh/site-functions/_streamlink
when installing the wheel.
The
sdist
andbuild
targets of setup.py don't include these optional data files.Third party packagers of Streamlink can build the completion files via
shtab
themselves:or
For BASH, this requires the
bash-completion
package to be installed and it'll look up the completion files automatically.https://github.com/scop/bash-completion/blob/master/README.md
For ZSH, the local completion path needs to be added to the config's
fpath
(I believe). I'm not a ZSH user, but the global path seems to be correct from what I can tell (according to Arch Linux's packaging at least). A confirmation would be appreciated.