Skip to content

Commit 278d655

Browse files
committed
docs: document new feature
1 parent 3c35ec4 commit 278d655

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,39 @@ you may instead reuse the same constant in your ``setup.py`` file:
128128
version=VERSION
129129
)
130130
131+
dynamic version attribute in ``pyproject.toml``
132+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133+
134+
A more modern approach in Python is to use ``pyproject.toml`` for building packages.
135+
136+
Some build systems that use ``pyproject.toml`` allow setting the version dynamically
137+
by allowing users to point to an attribute of some module in order to get the version.
138+
139+
One of such packages is setuptools. When using it, one can use the following:
140+
141+
.. code:: toml
142+
143+
[project]
144+
dynamic = ["version"]
145+
...
146+
147+
[build-system]
148+
requires = ["setuptools >= 70.0"]
149+
build-backend = "setuptools.build_meta"
150+
151+
[tool.setuptools.dynamic]
152+
version = {attr = "version_query.local_git_version.PREDICTED"}
153+
154+
Depending on how you build your package, the build system may copy files to a temporary folder
155+
when building. In such case, you need to set ``PROJECT_FOLDER`` environment variable
156+
to the current working directory before running the build command.
157+
158+
For example, when using ``build`` package:
159+
160+
.. code:: bash
161+
162+
PROJECT_FOLDER=$(pwd) python3 -m build
163+
131164
Versioning scheme
132165
=================
133166

0 commit comments

Comments
 (0)