Python:在基于 distutils 的项目中安装手册页
我有一个 Python 项目,它基本上是一组命令行脚本和一个帮助程序包。由于这些脚本有许多命令行选项,我决定为每个脚本创建一个手册页并使用 ronn (http: //rtomayko.github.com/ronn/)用 Markdown 编写手册并从中生成 mdoc。
问题是:如何在基于 distutils 的项目中生成和安装手册页?
我想出了以下解决方案:创建一个简单的 install.sh 脚本来生成并安装手册页。我从重载的“install”命令调用此脚本并将指定的前缀传递给它...您可以在此处检查实际代码: http://github.com/novel/lc-tools。
我不太喜欢这个解决方案,因为对于简单的任务,我必须向 setup.py 添加一些 hack 并实现一个 shell 脚本。此外,我使用 ${PREFIX}/share/man 作为手册页路径,这对于所有系统来说并不正确,例如 FreeBSD 似乎将第 3 方手册页安装到 /usr/local/man (即没有 share/)。
有更优雅的方法来做到这一点吗?
I have a Python project which is basically a set of command line scripts and a helper package. As these scripts have a number of command line options I decided to create a manual page for each script and used ronn (http://rtomayko.github.com/ronn/) to write manuals in Markdown and generate mdoc from it.
The question is: how to generate and install man pages in distutils based project?
I came up with the following solution: create an simple install.sh script which generates and installs manual pages. I call this script from the overloaded 'install' command and pass specified prefix to it... you can check actual code here: http://github.com/novel/lc-tools.
I don't quite like this solution as for the simple task I have to add some hacks to setup.py and implement a shell script as well. Moreover, I use ${PREFIX}/share/man for man page path and it's not correct for all systems, e.g. FreeBSD seem to install 3rd party man pages to /usr/local/man (i.e. no share/).
Are there more elegant ways to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
distutils 不支持手册页。人们编写了扩展来支持它们,通常采用自定义 distutils 命令的形式。例如,请参阅 Ubuntu 中的 python-distutils-extra。
distutils2 将支持安装手册页。
distutils does not support man pages. People have written extensions to support them, generally in the form of a custom distutils command. See for example python-distutils-extra from Ubuntu.
distutils2 will support installing man pages.
setup.py 中的小技巧可以解决问题...作为补充,您可以添加一个特殊的 man_prefix 选项,可以在设置时传递该选项来更改 man 路径。
你可以这样做:
Your little hack in your setup.py does the trick.... In complement, you can add a special man_prefix options that can be passed at setup time to change the man path.
You can do this like this :