My Python project includes some manpages and bash completion script. I want those to be installed when user installs a package with, for example, pip install mypackage. How do I do that? I only came across a very barbaric way of doing so by calling an external script (for example an .sh script) in the setup.py. Is there a more elegant approach?

有帮助吗?

解决方案

I'm sorry, but Python knows nothing about bash, or man, or other things you might take for granted. For instance, Windows, a widely deployed platform supported by Python, has neither. Other platforms, even Unix-like, may not have bash, too (e.g. using busybox) and would rather not spend storage space on man pages. Some users don't even have bash installed on capable systems (and use zsh for interactive work and ash for scripts).

So please limit your egg archive to things that only require Python, or Python extensions.

If you want to install other files, you have a few options.

  1. Publish an archive that contains both a setup.py for your package and whatever optional files you might want to include, possibly with an installation script for them, too.
  2. Create proper packages for the OSes you target. The rest will use option 1.
  3. Run the extra installations steps from your setup script (not recommended).

Also, you don't have to provide a man page, just support --help well. E.g. easy_install on Debian does not have a man page, and I'm fine with it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top