xcookie cookie-cutter 模块
项目描述
《xcookie》模块。一个用于模板化Python项目的辅助工具。
阅读文档 |
|
Github |
|
Pypi |
目标是能够使用一致的样板文件设置和更新Python项目结构,例如CI、setup.py 和需求。
它处理
多个版本控制远程
Github
Gitlab
纯Python包
具有scikit-build二进制扩展的Python包
轮换密钥
为github或gitlab的CI脚本,其中通用模式是
检查项目
构建纯Python或二进制轮
在支持的环境中测试轮(例如不同的操作系统/Python版本)
可选地使用在线GPG密钥签名轮
将轮上传到测试PyPI或实时PyPI。
这主要是由我的项目需求驱动的,因此有一些特定的逻辑。但是,这些逻辑都位于“erotemic”标签的检查之后。我正在慢慢将其开发成一个可以外部使用的正确CLI。
顶级CLI是
positional arguments:
repodir path to the new or existing repo
options:
-h, --help show this help message and exit
--repodir REPODIR path to the new or existing repo (default: .)
--repo_name REPO_NAME
defaults to ``repodir.name`` (default: None)
--mod_name MOD_NAME The name of the importable Python module. defaults to ``repo_name`` (default: None)
--pkg_name PKG_NAME The name of the installable Python package. defaults to ``mod_name`` (default: None)
--rel_mod_parent_dpath REL_MOD_PARENT_DPATH
The location of the module directory relative to the repository root. This defaults to simply placing the module in
".", but another common pattern is to specify this as "./src". (default: .)
--rotate_secrets [ROTATE_SECRETS], --no-rotate_secrets
If True will execute secret rotation (default: auto)
--refresh_docs [REFRESH_DOCS], --no-refresh_docs
If True will refresh the docs (default: auto)
--os OS all or any of win,osx,linux (default: all)
--is_new IS_NEW If the repo is detected or specified as being new, then steps to create a project for the repo on github/gitlab and
other initialization procedures will be executed. Otherwise we assume that we are updating an existing repo. (default:
auto)
--min_python MIN_PYTHON
--typed TYPED Should be None, False, True, partial or full (default: None)
--supported_python_versions SUPPORTED_PYTHON_VERSIONS
can specify as a list of explicit major.minor versions. Auto will use everything above the min_python version (default:
auto)
--ci_cpython_versions CI_CPYTHON_VERSIONS
Specify the major.minor CPython versions to use on the CI. Will default to the supported_python_versions. E.g. ["3.7",
"3.10"] (default: auto)
--ci_pypy_versions CI_PYPY_VERSIONS
Specify the major.minor PyPy versions to use on the CI. Defaults will depend on purepy vs binpy tags. (default: auto)
--ci_versions_minimal_strict CI_VERSIONS_MINIMAL_STRICT
todo: sus out (default: min)
--ci_versions_full_strict CI_VERSIONS_FULL_STRICT
--ci_versions_minimal_loose CI_VERSIONS_MINIMAL_LOOSE
--ci_versions_full_loose CI_VERSIONS_FULL_LOOSE
--remote_host REMOTE_HOST
if unspecified, attempt to infer from tags (default: None)
--remote_group REMOTE_GROUP
if unspecified, attempt to infer from tags (default: None)
--autostage AUTOSTAGE
if true, automatically add changes to version control (default: False)
--visibility VISIBILITY
or private. Does limit what we can do (default: public)
--version VERSION repo metadata: url for the project (default: None)
--url URL repo metadata: url for the project (default: None)
--author AUTHOR repo metadata: author for the project (default: None)
--author_email AUTHOR_EMAIL
repo metadata (default: None)
--description DESCRIPTION
repo metadata (default: None)
--license LICENSE repo metadata (default: None)
--dev_status DEV_STATUS
--enable_gpg ENABLE_GPG
--defaultbranch DEFAULTBRANCH
--xdoctest_style XDOCTEST_STYLE
type of xdoctest style (default: google)
--ci_pypi_live_password_varname CI_PYPI_LIVE_PASSWORD_VARNAME
variable of the live twine password in your secrets (default: TWINE_PASSWORD)
--ci_pypi_test_password_varname CI_PYPI_TEST_PASSWORD_VARNAME
variable of the test twine password in your secrets (default: TEST_TWINE_PASSWORD)
--regen REGEN if specified, any modified template file that matches this pattern will be considered for re-write (default: None)
--tags [TAGS ...] Tags modify what parts of the template are used. Valid tags are: "binpy" - do we build binpy wheels? "erotemic" - this
is an erotemic repo "kitware" - this is an kitware repo "pyutils" - this is an pyutils repo "purepy" - this is a pure
python repo "gdal" - add in our gdal hack # TODO "cv2" - enable the headless hack "notypes" - disable mypy in lint
checks (default: auto)
--interactive INTERACTIVE
--yes YES Say yes to everything (default: False)
--linter LINTER if true enables lint checks in CI (default: True)
创建新github仓库的调用
# Create a new python repo
python -m xcookie.main --repo_name=cookiecutter_purepy --repodir=$HOME/code/cookiecutter_purepy --tags="github,purepy"
# Create a new binary repo
python -m xcookie.main --repo_name=cookiecutter_binpy --repodir=$HOME/code/cookiecutter_binpy --tags="github,binpy,gdal"
给定一个初始化的仓库,一般的用法是编辑生成的 pyproject.toml 文件,并修改 [tool.xcookie] 部分的值,然后在该目录下重新运行 xcookie。然后它会向您展示建议的更改的diff,您可以拒绝、完全接受或选择性接受。
对于一些用户可能需要自定义工作的文件,xcookie 除非您告诉它重新生成,否则不会尝试覆盖文件。setup.py 是主要例子,所以如果您想更新 setup.py,则运行 xcookie --regen setup.py
对于旋转密钥,接口有点奇怪。由于一些密钥工具的交互性质,我没有在 xcookie 调用中使其工作,但如果您运行 xcookie --rotate-secrets,当它问您 "Ready to rotate secrets?" 时,回答“否”,它会列出它将运行的命令。因此,您可以手动复制/粘贴这些命令。我希望能使这在未来更容易。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分布
构建分布
xcookie-0.2.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 330083b5daee9089847292ebc31405b2ed38f2c4bccd0e788c9a45f480b93490 |
|
MD5 | c7747f421a21de46230b723e45d0d094 |
|
BLAKE2b-256 | e9fb9a6a5938897605164be1696a0027479c0c03a6c2047fc8871d631d4cbb44 |
xcookie-0.2.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 08e689cc1e9e4c6633b7d65d7d77e1fbe0f15bf8bf487b905c0e44f9057714c8 |
|
MD5 | 82756d2cd6b055d2bef619a2c0a8dbc7 |
|
BLAKE2b-256 | 34502c7f91280d2c6a1a2e096cdd728c21096262f4ff570530c19bc0010c2434 |