用于像pro一样提升项目版本的库
dephell-versioning的Python项目详细描述
deshell版本控制
用于碰撞项目版本的库。
可用方案:
- calver
- comver
- pep
- roman
- romver
- semver
- serial
- zerover
可用规则(和别名):
- init–初始化版本控制
- 主要部件:
- major(breaking)
- minor(feature)
- patch(fix,micro)
- 附加部分:
- dev
- local
- post
- 发布前管理:
- pre(rc,alpha,beta)
- premajor(prebreaking)
- preminor(prefeature)
- prepatch(prefix,premicro)
- release
阅读dephell project bump文档中有关方案和规则的更多信息。
用法
获取可用的方案、规则和别名:
fromdephell_versioningimportget_aliases,get_rules,get_schemesget_schemes()# frozenset({'roman', 'pep', ..., 'comver'})get_rules()# frozenset({'local', 'minor', ..., 'dev', 'preminor'})get_aliases()# frozenset({'alpha', 'rc', ..., 'micro', 'breaking'})# get rules for some scheme:get_rules(scheme='calver')# frozenset({'major', 'patch', 'init'})# get aliases for specific rules:get_aliases(rules={'major','minor'})# frozenset({'feature', 'breaking'})
凹凸版本:
fromdephell_versioningimportbump_versionbump_version(version='1.2.3',rule='minor',scheme='semver')# '1.3.0'# pass aliase instead of rule:bump_version(version='1.2.3',rule='feature',scheme='semver')# '1.3.0'# start rule from `+` to attach local version number:bump_version(version='1.2.3',rule='+456',scheme='semver')# '1.2.3+456'# for `init` version is optionalbump_version(version='',rule='init',scheme='semver')# '0.1.0'
python文件中的bump版本:
fromdephell_versioningimportbump_filefrompathlibimportPath# returns `True` if version was bumpedbump_file(path=Path('dephell_versioning','__init__.py'),old='0.1.0',new='0.1.1')# True# old version is optional: any version will be bumped if old isn't foundbump_file(path=Path('dephell_versioning','__init__.py'),old='',new='0.1.2')# True
使用dephell_discover查找python项目中的当前版本:
fromdephell_discoverimportRootfrompathlibimportPathroot=Root(path=Path(),name='dephell_discover')# root.metainfo can be None if project isn't found in the given directoryifroot.metainfo:print(root.metainfo.version)# '0.1.2'