繁体   English   中英

分发、epydoc 和 setup.py

[英]Distribute, epydoc, and setup.py

我想要一个为我的包运行 epydoc 的目标(比如docs )。 我假设我需要创建一个新命令,但我运气不佳。

以前有人这样做过吗?

Babel 项目提供了几个用于setup.py文件的命令。

您需要使用命令定义一个distutils.commands入口点; Babel setup.py文件中的示例:

entry_points = """
[distutils.commands]
compile_catalog = babel.messages.frontend:compile_catalog
extract_messages = babel.messages.frontend:extract_messages
init_catalog = babel.messages.frontend:init_catalog
update_catalog = babel.messages.frontend:update_catalog
"""

然后额外的命令可以作为python setup.py commandname

入口点指向from distutils.cmd import Command子类。 再次来自 Babel 的示例,来自babel.messages.frontend模块

from distutils.cmd import Command
from distutils.errors import DistutilsOptionError


class compile_catalog(Command):
    """Catalog compilation command for use in ``setup.py`` scripts."""

    # Description shown in setup.py --help-commands
    description = 'compile message catalogs to binary MO files'
    # Options available for this command, tuples of ('longoption', 'shortoption', 'help')
    # If the longoption name ends in a `=` it takes an argument
    user_options = [
        ('domain=', 'D',
         "domain of PO file (default 'messages')"),
        ('directory=', 'd',
         'path to base directory containing the catalogs'),
        # etc.
    ]
    # Options that don't take arguments, simple true or false options.
    # These *must* be included in user_options too, but without a = equals sign
    boolean_options = ['use-fuzzy', 'statistics']

    def initialize_options(self):
        # Set a default for each of your user_options (long option name)

    def finalize_options(self):
        # verify the arguments and raise DistutilOptionError if needed

    def run(self):
        # Do your thing here.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM