gpt4 book ai didi

python - 分发、epydoc 和 setup.py

转载 作者:行者123 更新时间:2023-12-01 05:53:00 28 4
gpt4 key购买 nike

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

以前有人这样做过吗?

最佳答案

Babel project提供了在 setup.py 文件中使用的多个命令。

您需要使用命令定义一个 distutils.commands 入口点;示例来自Babel setup.py file :

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 module :

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.

关于python - 分发、epydoc 和 setup.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529722/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com