python包的可靠的基于git的版本控制

katversion的Python项目详细描述


katversion包为python包提供适当的版本控制,如下所示 由他们的(git)源代码库决定。生成的版本字符串是 烘焙到已安装包的__init__.py文件中,以保证 导入时的可跟踪性(不依赖于pkg_资源的想法!).

版本字符串格式

katversion为您的scm包生成一个版本字符串 符合PEP 440。 它主要支持git存储库,并半心半意地尝试svn支持。

我们版本字符串的格式是:

- for RELEASE builds:
    <major>.<minor>
    e.g.
    0.1
    2.4

- for DEVELOPMENT builds:
    <major>.<minor>.dev<num_commits>+<branch_name>.g<short_git_sha>[.dirty]
    e.g.
    0.2.dev34+new.shiny.feature.gfa973da
    2.5.dev7+master.gb91ffa6.dirty

- for UNKNOWN builds:
    0.0+unknown.[<scm_type>.]<timestamp>
    e.g.
    0.0+unknown.svn.201402031023
    0.0+unknown.201602081715

where <major>.<minor> is derived from the latest version tag and
<num_commits> is the total number of commits on the development branch.

The <major>.<minor> substring for development builds will be that of the
NEXT (minor) release, in order to allow proper Python version ordering.

To add a version tag use the `git tag` command, e.g.

    $ git tag -a 1.2 -m 'Release version 1.2'

典型用法

将此添加到setup.py(处理已安装的软件包):

fromsetuptoolsimportsetupsetup(...,setup_requires=['katversion'],use_katversion=True,...)

将此添加到mypackage/__init__.py,包括注释行 (处理本地包):

# BEGIN VERSION CHECK# Get package version when locally imported from repo or via -e develop installtry:importkatversionas_katversionexceptImportError:# pragma: no coverimporttimeas_time__version__="0.0+unknown.{}".format(_time.strftime('%Y%m%d%H%M'))else:# pragma: no cover__version__=_katversion.get_version(__path__[0])# END VERSION CHECK

此外,还有一个用于检查版本的命令行脚本:

# From inside your SCM subdirectory, run the following command
# which will print the result to stdout:
$ kat-get-version.py

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用EntityManager有没有更有效的习惯用法?   Android上的java Google应用程序引擎(GAE)响应代码和cookie   如何在Java中创建单元测试?   java从DB获取特定列的最新行   java替换所有悬空元字符   java使用Hibernate删除SQL表中的数据   swing显示JComponent对象Java   java在确认内容类型后如何将URL保存到文件?   javascript如何从段落中选择大量单词?(硒)   java在Linux上使用BundleEnableTiveCode不起作用   java使用日志似然性来比较不同的mallet主题模型?   java无法在Tomcat7上运行Spring Boot 2.0:“由于缺少ServletWebServerFactory bean,无法启动ServletWebServerApplicationContext。”   java有办法显式引用非静态内部类实例吗?   java如何使用Spring的NamedParameterJdbcTemplate在MySQL数据库中创建和删除表?