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?
- Python 3.11.6 on MacOS 14.1.2 (Sonoma)
setuptools
version 68.2.2pip
version 23.3.1
Package 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__"}
- Command:
python -m build
- Screen output:
...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
anddist/invperc-0.0.0-py3-none-any-whl
now exist with0.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'