Python 安装工具根据通用命名约定规范版本名称

标签 python python-3.x setuptools

错误

/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

流行的命名约定。

有没有办法修复这种感觉!

最佳答案

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

Different Python projects may use different versioning schemes based on the needs of that particular project, but all of them are required to comply with the flexible public version scheme specified in PEP 440 in order to be supported in tools and libraries like pip and setuptools.

PEP 440 只允许使用五个后缀:abrcpostdev .

另请注意,ab 后缀标识 alpha 和 beta 版本,因此请检查您的版本控制方案是否反射(reflect)了这一点(workbench 分支是否反射(reflect)了这一点)真的包含 alpha 版本吗?)。

如果需要在版本中存储附加信息,可以使用local version identifier分隔版本部分。示例:

1.2.3+spam
1.0.0.dev999+eggs123.bacon456

但是,再次重申 PEP 440:

Local version identifiers SHOULD NOT be used when publishing upstream projects to a public index server, but MAY be used to identify private builds created directly from the project source. [...] As the Python Package Index is intended solely for indexing and hosting upstream projects, it MUST NOT allow the use of local version identifiers.

关于Python 安装工具根据通用命名约定规范版本名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60323764/

相关文章:

python - 如何根据分组中的最大值快速删除行?

python - 如何解决 Fenics 示例 ft06_elasticity.py 中名称 'nabla_div' 未定义错误?

python - peewee:Python int 太大而无法转换为 SQLite INTEGER

python - 为什么 ~/.pyenv/versions/*/bin 中的脚本不能从命令行调用?

python - setuptools python - 项目内导入问题

python - 使用 xgboost 绘制特征重要性

python - 创建霍夫曼代码时如何处理 '/n' ,'/t' 和类似的 ascii 键

python - 如何使用 install_requires 安装 git+https ://from setup. py

python 在根脚本中以普通用户身份运行命令

python - 类定义中的变量范围令人困惑