I am using setuptools with a pyproject.toml file, and want setuptools to get the package version dynamically from the package contents. Instead, it is always setting the package version in the name of the generated file to 0.0.0, even though the package version inside the package seems correct. What am I doing wrong?
setuptools version 68.2.2pip version 23.3.1Package structure:
.
├── LICENSE.md
├── README.md
├── invperc
│ └── __init__.py
└── pyproject.toml
invperc/__init__.py contains only this:__version__ = "0.2.0"
pyproject.toml contains only this:[project]
name = "invperc"
description = "Invasion Percolation"
readme = "README.md"
authors = [
{ name = "Greg Wilson", email = "[email protected]" }
]
license = { text = "MIT License" }
dependencies = ["pandas", "numpy"]
dynamic = ["version"]
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tools.setuptools.dynamic]
version = {attr = "invperc.__version__"}
python -m build
...many lines...
Successfully built invperc-0.0.0.tar.gz and invperc-0.0.0-py3-none-any.whl
dist/invperc-0.0.0.tar.gz and dist/invperc-0.0.0-py3-none-any-whl now exist with 0.0.0 as version numbers (which is incorrect).
But if I import and check:
$ cd /tmp
$ pip install $HOME/invperc/dist/invperc-0.0.0-py3-none-any.whl
$ python
>>> import invperc
>>> invperc.__version__
'0.2.0'
Thanks to @[email protected] for the answer: [tools.setuptools.dynamic] should be [tool.setuptools.dynamic] with a singular "tool" instead of a plural "tools". Now excuse me while I go scream into a pillow about the lack of any kind of warning message...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With