How to indicate use_scm_version in setup.cfg?
Question:
I’m switching from using setup.py
to setup.cfg
.
How can I indicate in setup.cfg
that I want use_scm_version= True
?
Answers:
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"},
)
I have resolved this by adding pyproject.toml
file with following code, forcing building to be implemented with 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"
See the recommended usage in project.toml:
# project.toml
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
[project]
dynamic = ["version"] # remove any existing version parameter
[tool.setuptools_scm]
According to the setuptools-scm docs, this is equivalent to supplying use_scm_version=True
in setup.py
.
I’m switching from using setup.py
to setup.cfg
.
How can I indicate in setup.cfg
that I want 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"},
)
I have resolved this by adding pyproject.toml
file with following code, forcing building to be implemented with 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"
See the recommended usage in project.toml:
# project.toml
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
[project]
dynamic = ["version"] # remove any existing version parameter
[tool.setuptools_scm]
According to the setuptools-scm docs, this is equivalent to supplying use_scm_version=True
in setup.py
.