Skip to main content

nltbuild

Project description

nltbuild

PyPI version Python License: MIT

nltbuild 是面向 Python / 混合仓库的构建与发布辅助工具:根据项目结构自动选择构建策略(UV、Poetry、旧式 PyPI 脚本、package.json 前端包及混合模式等),串联版本递增、构建、安装校验、发布与 Git 标签等常见流程。

特性

  • 多构建策略:按仓库布局自动匹配 UVBuildPoetryBuildPypiBuildNpmFrontendBuildUvNpmHybridBuild 等实现,无需手写切换逻辑。
  • 版本同步:以根目录 pyproject.toml[project].version 为主源时,可将版本同步到仓内其它带 versionpyproject.tomlpackage.json(含子目录)。
  • 依赖与工具链:内置对 uvruff 等工具的调用约定;日志通过 nltlog,Shell 流程通过 funshell
  • Git 工作流pull / push / tags 等与远程协作;push 默认在提交阶段使用 aicommits 生成说明(需本机已安装该 CLI)。
  • 维护命令cleanclean_history 会改写 Git 状态或强制重写远程历史,使用前请确认团队规范与备份策略。

系统要求

  • Python 3.9+
  • Git(版本管理与标签推送)
  • 若使用 nltbuild push 的默认行为:本机需可用 aicommits(例如 npm install -g aicommits 并按其文档配置)

安装

从 PyPI 安装

pip install nltbuild

从源码安装

git clone https://github.com/farfarfun/nltbuild.git
cd nltbuild
pip install .

使用 uv 时,可在克隆后执行 uv syncuv pip install -e . 进行可编辑安装。

使用说明

在项目根目录执行 nltbuild 子命令(入口由 pyproject.toml[project.scripts] 注册为 nltbuild)。

版本

# 按内置策略自增并写回各清单文件
nltbuild upgrade

当前 CLI 未暴露「写入指定版本号」参数;需要固定版本时请直接编辑 pyproject.toml 等清单后再提交。

Git

nltbuild pull

# 默认:git add -A → aicommits --yes → git push
nltbuild push

构建与发布

# 本地构建并安装 wheel、执行发布命令(依具体 Build 实现而定),随后 push 与打标签
nltbuild build

# 仅构建并安装到当前环境(不执行完整 publish + 推送流水线时,请直接调用底层工具,例如 uv build)
nltbuild install

nltbuild build 在基类实现中会依次触发:pullupgrade → 构建/安装/发布/清理 → pushtags。实际命令序列取决于选中的 Build 类型。

维护类(高风险)

# 清理 Git 缓存与索引(会生成提交)
nltbuild clean

# 清空标签并重写远程 master(破坏性操作,仅限明确需要「清历史」的仓库)
nltbuild clean_history

nltbuild tags

配置说明

  • Python 项目:在根目录 pyproject.toml 中维护 [project].version 与依赖;UV 类构建会读写该版本并同步到其它清单。
  • 纯前端 / 子包:在对应 package.json 中可使用 nltbuild 字段(对象或 true)扩展行为(例如自定义 build 命令、cleanDirs 等),具体逻辑见源码中 NpmFrontendBuild

构建类型的判定顺序见 src/nltbuild/core/registry.py 中的注册表;无需再使用旧文档中的 [tool.funbuild] 等虚构段名。

集成组件

  • uv — 包管理与构建
  • ruff — Lint / 格式化(按项目配置使用)
  • typertyper-slim)— CLI 框架
  • aicommits — 默认与 push 流水线集成的提交信息生成(以本机 CLI 为准)

仓库布局(摘要)

nltbuild/
├── src/
│   └── nltbuild/
│       ├── core/       # 构建注册与各策略实现
│       └── tool/       # 附加工具入口
├── pyproject.toml
└── README.md

参与贡献

  1. Fork nltbuild
  2. 新建分支并提交变更
  3. 发起 Pull Request

本地开发示例:

git clone https://github.com/farfarfun/nltbuild.git
cd nltbuild
uv pip install -e .
# 或: pip install -e .

ruff format .
ruff check . --fix

许可证

本项目以 MIT 许可证 发布。

链接

维护者

若 nltbuild 对你有帮助,欢迎点个 Star。

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

nltbuild-1.6.49-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file nltbuild-1.6.49-py3-none-any.whl.

File metadata

  • Download URL: nltbuild-1.6.49-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","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":null}

File hashes

Hashes for nltbuild-1.6.49-py3-none-any.whl
Algorithm Hash digest
SHA256 eeb23129bfd649cec98967f2d817480bc72c074d8bd6ee96affea52176476150
MD5 ea57f533699ebb50f901fd7baa66a1d6
BLAKE2b-256 b9ea953071a38a17184a7ec2593178efbc056136a35a2239a0b11c1738597a4b

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