简体   繁体   English

如何在 setup.cfg 中指明 use_scm_version?

[英]How to indicate use_scm_version in setup.cfg?

I'm switching from using setup.py to setup.cfg .我正在从使用setup.py切换到setup.cfg How can I indicate in setup.cfg that I want use_scm_version= True ?如何在setup.cfg中指出我想要use_scm_version= True

Did you try the following:您是否尝试过以下操作:

from setuptools import setup
from setuptools.config import read_configuration

conf_dict = read_configuration("setup.cfg")
PKG_NAME = conf_dict['metadata']['name']

setup(
    use_scm_version={"write_to": f"{PKG_NAME}/_version.py"},
)

Source: https://github.com/pypa/setuptools_scm/issues/582来源: https://github.com/pypa/setuptools_scm/issues/582

I have resolved this by adding pyproject.toml file with following code, forcing building to be implemented with setuptools_scm :我通过添加带有以下代码的pyproject.toml文件解决了这个问题,强制使用setuptools_scm实现构建:

# pyproject.toml
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_scheme = "post-release"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM