File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,39 @@ you may instead reuse the same constant in your ``setup.py`` file:
128
128
version = VERSION
129
129
)
130
130
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
+
131
164
Versioning scheme
132
165
=================
133
166
You can’t perform that action at this time.
0 commit comments