Python设置工具根据通用命名约定对版本名称进行归一化

问题描述 投票:1回答:1

错误

/root/.local/lib/python3.7/site-packages/setuptools/dist.py:476: UserWarning: Normalizing '2.1.0c1' to '2.1.0rc1'
  normalized_version,
[Pipeline] sh
+ python3 -m twine upload --config-file .pypirc -r nesus dist/forecasting_model-2.1.0c1.tar.gz
InvalidDistribution: Cannot find file (or expand pattern): 'dist/forecasting_model-2.1.0c1.tar.gz'

我的命名约定代码

 model_version_trunc = re.split("a|b|c", current_version)[0] if len(re.split("a|b|c", current_version)) > 0 else current_version
    sub_version = int(re.split("a|b|c", current_version)[1]) if len(re.split("a|b|c", current_version)) > 1 else 1
    VERSION = current_version

    if BRANCH == 'workbench':
        letter = 'a'
    elif BRANCH == 'development':
        letter = 'b'
    elif BRANCH == 'master':
        sub_version = ''
        letter = ''
    else:
        letter = 'c'

    VERSION = f'{model_version_trunc}{letter}{sub_version}'

    # Check Version
    session = HTMLSession()
    r = session.get(MODEL_LIBRARY)
    versions_so_far = r.html.links
    version_already_exists = list(set([f'{VERSION}/']).intersection(versions_so_far))
    logger.info(f'Updated Version: {VERSION}')
    logger.info(f'Version Exists: {version_already_exists}')

    if len(version_already_exists) > 0:
        for x in version_already_exists:
            ''' 
                Fallback if versions are similar:

                If a version is an alpha/beta/branch release, update the release number
                If a version is just the standard version then udpate the minor version.
            '''

我在这里检查了链接-

https://packaging.python.org/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme

用于流行的命名约定。

有没有一种方法可以解决这种问题!

python python-3.x setuptools
1个回答
1
投票

您的版本方案与PEP 440不兼容。您在问题中提到的链接明确指出:

不同的Python项目可能会根据特定项目的需要使用不同的版本控制方案,但是它们都必须符合PEP 440中指定的灵活的公共版本方案为了在工具和库中得到支持像pipsetuptools

PEP 440仅允许五个后缀:abrcpostdev

还请注意,ab后缀标识Alpha和Beta版本,因此请检查您的版本控制方案是否反映了这一点(workbench分支是否确实包含Alpha版本?]]

如果需要在版本中存储其他信息,则可以使用local version identifier分隔版本部分。范例:

1.2.3+spam
1.0.0.dev999+eggs123.bacon456

但是,再次重申PEP 440:

本地版本标识符在将上游项目发布到公共索引服务器时不应该使用,但是可以用来标识直接从项目源创建的私有版本。 [...]由于Python包索引仅用于索引和托管上游项目,因此它绝对不允许使用本地版本标识符。

© www.soinside.com 2019 - 2024. All rights reserved.