Skip to main content

基于 [copier](https://copier.readthedocs.io/) 的通用 Python 项目模板。

Project description

coopie

基于 copier 的通用 Python 项目模板,一键生成开箱即用的工程骨架。

CI PyPI Python License Coverage

快速开始

# 新建项目到子目录
coopie new my-project

# 或在当前目录初始化(项目名从目录名派生)
cd existing-dir && coopie init

coopie 自动从 git 配置读取作者信息,生成包含构建工具链(uv + ruff + pyrefly + pytest)、CI/CD、文档与测试的完整项目。也可直接用 uvx copier copy https://github.com/gookeryoung/coopie.git <目标> 调用 copier。

更新已有项目

模板更新后,在已生成的项目目录中运行:

coopie update         # 增量合并模板更新
coopie update -A      # 跳过问题(使用上次答案)
coopie test           # dry-run 检查是否产生冲突

CLI 命令

命令 说明
coopie new <name> 新建项目(建立子目录)
coopie init 在当前目录初始化(非空目录提示确认)
coopie update [-A] [-T] 更新已生成项目模板
coopie test [-A] [-T] 模拟检查更新冲突(dry-run)
coopie -V 显示版本号

new/init 支持 --template <url|path> 指定模板源(URL 或本地路径),也可通过环境变量 COOPIE_TEMPLATE_REPO 覆盖默认 GitHub 仓库。国内网络访问 GitHub 缓慢时,可指定镜像或本地副本:

coopie new my-project --template https://ghproxy.com/https://github.com/gookeryoung/coopie
# 或
COOPIE_TEMPLATE_REPO=/path/to/local-coopie coopie new my-project

可配置选项

选项 类型 默认值 说明
project_name str my-project 项目名称
package_name str 自动派生 Python 包名
description str - 项目简短描述
author_name str git 配置 作者名称
author_email str git 配置 作者邮箱
min_python_version str 3.8 最低 Python 版本
max_python_version str 3.14 最高 Python 版本
license str MIT 许可证(MIT/Apache-2.0/GPL-3.0/None)
project_type str library 项目类型(library/cli/gui/web;gui 按 Python 版本区分 PySide2≤3.10 / PySide6≥3.11)
use_docs bool true Sphinx 文档
use_docker bool false Dockerfile
use_cicd bool true GitHub Actions CI/CD
use_tox bool true tox 多版本测试
use_cli bool false CLI 入口(project_type=cli 时自动启用)
use_domestic_mirrors bool true 国内镜像源
coverage_fail_under int 95 覆盖率阈值

生成后

cd my-project
uv sync --extra dev      # 安装依赖
uv run pytest            # 运行测试
make check               # 全套门禁(lint + typecheck + cov)

生成的项目自带 Makefile,运行 make help 查看全部命令(sync/build/clean/test/cov/lint/bump 等)。

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coopie-0.5.0.tar.gz (155.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coopie-0.5.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file coopie-0.5.0.tar.gz.

File metadata

  • Download URL: coopie-0.5.0.tar.gz
  • Upload date:
  • Size: 155.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for coopie-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d9f7a1c39080b7b3a24ebdb6827811a79d4d9398d893e89ddb66a5d0611a7623
MD5 da9640768a1ab77fe68354865b6f4d2d
BLAKE2b-256 1a04fb46f83dc5521a24395df70dc6f28aca67b9aa7060bea37241fc4a0676b2

See more details on using hashes here.

File details

Details for the file coopie-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: coopie-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for coopie-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af356795b428603317f3a52106b49b4cacf8170819a610a7d1a9b9d9f93ce701
MD5 dab88d4f2fac840716732a71af03cf15
BLAKE2b-256 8ae1dcb4a85ea9cf0bcb2ff2e0a16247ad4a5bbea5bede1e88a9807adaedcc1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page