Dynamic versioning with pyproject.toml #3630
-
Hi Folks, I'm using I am using a I've read through the dynamic metadata section of the docs. Repo LayoutI'm currently attempting to achieve dynamic versioning as follows (only including relevant portions of the repo structure):
The __version__ = f"{1}.{2}.{3}" # more complicated than this, but a simple example A snippet from the [project]
name = "mymodule"
dynamic = ["version"]
[build-system]
requires = ["setuptools>=61.0.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["."]
include = ["mymodule*"]
[tool.setuptools.dynamic]
version = {attr = "mymodule.__version__"} Current BehaviorBuilding a wheel and dist with
Configuring the __version__ = "1.2.3" Is there a way to configure my project to include the dynamic versioning info by invoking a function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @rndubs, I cannot reproduce this error with the following experiment (in an isolated docker container): > docker run --rm -it python:3.7.2 /bin/bash
python -m pip install -U pip 'setuptools==65.4.1' build
mkdir -p /tmp/myproj/mymodule
cd /tmp/myproj
echo -e '__version__ = f"{1}.{2}.{3}"' > mymodule/__init__.py
cat <<EOS > pyproject.toml
[project]
name = "mymodule"
dynamic = ["version"]
[build-system]
requires = ["setuptools>=61.0.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["."]
include = ["mymodule*"]
[tool.setuptools.dynamic]
version = {attr = "mymodule.__version__"}
EOS
python -m build This successfully creates the If I replace the echo -e 'a = 4\nb = 5\nc = 6\n__version__ = f"{a}.{b}.{c}"' > mymodule/__init__.py and run |
Beta Was this translation helpful? Give feedback.
Hi @rndubs, I cannot reproduce this error with the following experiment (in an isolated docker container):
This successfully creates the
mymodul…