I want to include an upload environment in my tox.ini file.
But, that requires resolving the project version dynamically; something like:
[testenv:upload]
basepython = python3.11
skip_install = true
deps =
twine
commands =
twine upload dist/foo-{[project]version}.tar.gz dist/foo-{[project]version}-py3-none-any.whl
But, that syntax doesn't work:
% tox -e upload
upload: commands[0]> twine upload 'dist/foo-{[project]version}.tar.gz' 'dist/foo-{[project]version}-py3-none-any.whl'
ERROR InvalidDistribution: Cannot find file (or expand pattern): 'dist/foo-{[project]version}.tar.gz'
What is the correct syntax, in the tox.ini file, for reading the project version from the pyproject.toml file?
Tox itself does not have a global variable called
projectand if you want to get the project version from pyproject.toml, You could do thissetenvcommand to set the version.