跳转到主要内容

一个命令行工具,可以从项目模板创建项目,例如,从Python包模板创建Python包项目。

项目描述

cookiecutter Logo

pypi python Build Status codecov discord docs Code Quality

Cookiecutter

使用此命令行工具从 cookiecutter(项目模板)快速创建项目。非常适合生成Python软件包项目等。

安装

使用pip包管理器安装cookiecutter

# pipx is strongly recommended.
pipx install cookiecutter

# If pipx is not an option,
# you can install cookiecutter in your Python user directory.
python -m pip install --user cookiecutter

特性

  • 跨平台: 支持 Windows、Mac 和 Linux。
  • 用户友好: 无需Python知识。
  • 通用: 兼容Python 3.7至3.12。
  • 多语言支持: 使用任何语言或标记格式中的模板。

对于用户

快速入门

推荐使用pipx运行Cookiecutter作为命令行工具,pipx可以用pip安装,命令为pip install pipx。但如果您打算将Cookiecutter作为程序使用,请运行pip install cookiecutter

使用GitHub模板

# You'll be prompted to enter values.
# Then it'll create your Python package in the current working directory,
# based on those values.
# For the sake of brevity, repos on GitHub can just use the 'gh' prefix
$ pipx run cookiecutter gh:audreyfeldroy/cookiecutter-pypackage

使用本地模板

$ pipx run cookiecutter cookiecutter-pypackage/

在Python中使用

from cookiecutter.main import cookiecutter

# Create project from the cookiecutter-pypackage/ template
cookiecutter('cookiecutter-pypackage/')

# Create project from the cookiecutter-pypackage.git repo template
cookiecutter('gh:audreyfeldroy//cookiecutter-pypackage.git')

详细用法

  • 从本地或远程模板生成项目。
  • 使用cookiecutter.json提示自定义项目。
  • 使用预提示、预生成和后生成钩子。

了解更多

对于模板创建者

  • 利用无限目录嵌套。
  • 使用Jinja2满足所有模板需求。
  • 使用cookiecutter.json轻松定义模板变量。

了解更多

可用模板

GitHub上发现各种现成的模板。

特殊模板

社区

加入社区,贡献或寻求帮助。

支持

  • GitHub上关注我们。
  • 敬请期待即将推出的支持选项。

反馈

我们重视您的反馈。请建设性地分享您的批评或投诉,以帮助我们改进。

等待回复?

  • 请耐心,并考虑向社区寻求帮助。
  • 对于紧急事项,请联系@audreyfeldroy进行咨询或定制开发。

行为准则

在整个项目生态系统的所有互动中遵守PyPA行为准则

致谢

Audrey Roy Greenfeld创建并领导,由一支专门的维护者和贡献者团队支持。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

cookiecutter-2.6.0.tar.gz (158.8 kB 查看哈希值)

上传时间 源代码

构建分发

cookiecutter-2.6.0-py3-none-any.whl (39.2 kB 查看哈希值)

上传时间 Python 3

由以下机构支持