version-query 1.6.3.dev0__py3-none-any.whl → 1.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ """Use this module when reading the version from an attribute is needed without Python code.
2
+
3
+ For example, when using setuptools in pyproject.toml,
4
+ one can set the version dynamically as follows:
5
+
6
+ [project]
7
+ dynamic = ["version"]
8
+ ...
9
+
10
+ [tool.setuptools.dynamic]
11
+ version = {attr = "version_query.local_git_version.PREDICTED"}
12
+ """
13
+
14
+ import os
15
+ import pathlib
16
+
17
+ from .git_query import query_git_repo, predict_git_repo
18
+
19
+ _CURRENT_FOLDER: pathlib.Path = pathlib.Path()
20
+ _PROJECT_FOLDER: pathlib.Path = pathlib.Path(os.environ.get('PROJECT_FOLDER', _CURRENT_FOLDER))
21
+ QUERIED: str = query_git_repo(_PROJECT_FOLDER).to_str()
22
+ PREDICTED: str = predict_git_repo(_PROJECT_FOLDER).to_str()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: version-query
3
- Version: 1.6.3.dev0
3
+ Version: 1.7.0
4
4
  Summary: Zero-overhead package versioning for Python.
5
5
  Home-page: https://github.com/mbdevpl/version-query
6
6
  Download-URL:
@@ -81,7 +81,7 @@ Zero-overhead package versioning for Python.
81
81
  :alt: grade from Codacy
82
82
 
83
83
  .. image:: https://img.shields.io/github/license/mbdevpl/version-query.svg
84
- :target: https://github.com/mbdevpl/version-query/blob/v1.6.3.dev0/NOTICE
84
+ :target: https://github.com/mbdevpl/version-query/blob/v1.7.0/NOTICE
85
85
  :alt: license
86
86
 
87
87
  Package versioning toolkit for Python which relies on git tags, git history traversal
@@ -94,34 +94,43 @@ for easier development, testing and pre-release deployment?!
94
94
 
95
95
  Search no more!
96
96
 
97
- As long as you mark your releases using git tags, instead of hardcoding:
97
+ As long as you use git and you mark your releases using git tags, version-query will do the rest.
98
98
 
99
- .. code:: python
99
+ It's 21st century, stop hardcoding version numbers!
100
100
 
101
- __version__ = '1.5.0.dev2'
101
+ .. contents::
102
+ :backlinks: none
102
103
 
103
- You can do:
104
104
 
105
- .. code:: python
105
+ Overview
106
+ ========
106
107
 
107
- from version_query import predict_version_str
108
+ There are two main ways of using version-query - at runtime or at build time.
108
109
 
109
- __version__ = predict_version_str()
110
+ Using at runtime
111
+ ----------------
110
112
 
111
- It's 21st century, stop hardcoding version numbers!
113
+ When using this way, version-query is needed as a runtime dependency of your package.
112
114
 
113
- This will set the version to release version when you really release a new version,
114
- and it will automatically generate a suitable development version at development/pre-release phase.
115
+ If, for example, you have a constant storing the version of your package in some Python module:
115
116
 
117
+ .. code:: python
116
118
 
117
- .. contents::
118
- :backlinks: none
119
+ VERSION = '1.5.0.dev2'
119
120
 
121
+ You can do the following instead of hardcoding it:
120
122
 
121
- Overview
122
- ========
123
+ .. code:: python
123
124
 
124
- At development time, the current version number is automatically generated based on:
125
+ from version_query import predict_version_str
126
+
127
+ VERSION = predict_version_str()
128
+
129
+ This will set the version to release version when you really release a new version,
130
+ and it will automatically generate a suitable development version at development/pre-release phase.
131
+
132
+ When your package is imported while running from inside the repository, such as during development,
133
+ the current version number is automatically generated based on:
125
134
 
126
135
  * tags
127
136
  * current commit SHA
@@ -134,16 +143,88 @@ or at runtime) then the script relies on metadata generated at packaging time.
134
143
  That's why, regardless if package is installed from PyPI (from source or wheel distribution)
135
144
  or cloned from GitHub, the version query will work.
136
145
 
137
- Additionally, version numbers in version-query are mutable objects and they can be conveniently
138
- incremented, compared with each other, as well as converted to/from other popular
139
- versioning formats.
146
+ Using at build time
147
+ -------------------
148
+
149
+ This is the way to go if you want to use version-query only as a dependency when building
150
+ the package, in such case it's not necessary to to add it to runtime dependencies.
151
+
152
+ There are many build systems available for Python, and version-query may not be compatible
153
+ with all of them. Below are some examples.
154
+
155
+ setuptools with ``setup.py`` script
156
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157
+
158
+ This is a legacy way of building Python packages, but it is still widely used.
159
+
160
+ In such setup, you just need to add the following to your ``setup.py`` file:
161
+
162
+ .. code:: python
163
+
164
+ import setuptools
165
+ from version_query import predict_version_str
166
+
167
+
168
+ setuptools.setup(
169
+ ...,
170
+ version=predict_version_str()
171
+ )
172
+
173
+ If you are already using version-query at runtime in your package to set a constant
174
+ (for example ``my_package.VERSION``, please see "Using at runtime" section above for details),
175
+ you may instead reuse the same constant in your ``setup.py`` file:
176
+
177
+ .. code:: python
178
+
179
+ import setuptools
180
+
181
+ from my_package import VERSION
182
+
183
+
184
+ setuptools.setup(
185
+ ...,
186
+ version=VERSION
187
+ )
188
+
189
+ dynamic version attribute in ``pyproject.toml``
190
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191
+
192
+ A more modern approach in Python is to use ``pyproject.toml`` for building packages.
193
+
194
+ Some build systems that use ``pyproject.toml`` support setting the version dynamically
195
+ by allowing users to point to an attribute of some module in order to get the version.
196
+
197
+ One of such packages is setuptools. When using it, one can do the following:
198
+
199
+ .. code:: toml
200
+
201
+ [project]
202
+ dynamic = ["version"]
203
+ ...
204
+
205
+ [build-system]
206
+ requires = ["setuptools >= 70.0"]
207
+ build-backend = "setuptools.build_meta"
208
+
209
+ [tool.setuptools.dynamic]
210
+ version = {attr = "version_query.local_git_version.PREDICTED"}
211
+
212
+ Depending on how you build your package, the build system may copy files to a temporary folder
213
+ when building. In such case, you need to set ``PROJECT_FOLDER`` environment variable
214
+ to the current working directory before running the build command.
215
+
216
+ For example, when using ``build`` package:
217
+
218
+ .. code:: bash
219
+
220
+ PROJECT_FOLDER=$(pwd) python3 -m build
140
221
 
141
222
  Versioning scheme
142
223
  =================
143
224
 
144
225
  Version scheme used by version-query is a relaxed mixture of:
145
226
 
146
- * `Semantic Versioning 2.0.0 <http://semver.org/>`_ and
227
+ * `Semantic Versioning 2.0.0 <http://semver.org/>`__ and
147
228
 
148
229
  * `PEP 440 -- Version Identification and Dependency Specification <https://www.python.org/dev/peps/pep-0440/>`_.
149
230
 
@@ -328,7 +409,7 @@ The base specification of the comparison scheme is:
328
409
 
329
410
  * `PEP 508 -- Dependency specification for Python Software Packages <https://www.python.org/dev/peps/pep-0508/>`_ as well as
330
411
 
331
- * `Semantic Versioning 2.0.0 <http://semver.org/>`_.
412
+ * `Semantic Versioning 2.0.0 <http://semver.org/>`__.
332
413
 
333
414
  With the notable difference to both that all version components are taken into account when
334
415
  establishing version precedence.
@@ -426,7 +507,7 @@ The Version objects are mutable, hashable and comparable.
426
507
  version = version_query.query_caller(stack_level=1)
427
508
  version = version_query.predict_caller(2)
428
509
 
429
- Version object can be obtained for any supported path, as well as for any python code
510
+ Version object can be obtained for any supported path, as well as for any Python code
430
511
  currently being executed -- as long as it is located in a supported location.
431
512
 
432
513
 
@@ -491,8 +572,8 @@ Requirements
491
572
 
492
573
  Python version 3.9 or later.
493
574
 
494
- Python libraries as specified in `requirements.txt <https://github.com/mbdevpl/version-query/blob/v1.6.3.dev0/requirements.txt>`_.
575
+ Python libraries as specified in `requirements.txt <https://github.com/mbdevpl/version-query/blob/v1.7.0/requirements.txt>`_.
495
576
 
496
- Building and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/version-query/blob/v1.6.3.dev0/requirements_test.txt>`_.
577
+ Building and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/version-query/blob/v1.7.0/requirements_test.txt>`_.
497
578
 
498
579
  Tested on Linux, macOS and Windows.
@@ -2,6 +2,7 @@ version_query/__init__.py,sha256=HhcD74jXiiWlqw5AHgxu3S2EpDzVhYpXetWlNoebEu8,434
2
2
  version_query/__main__.py,sha256=uw0F743_RvxMCdmeFriHoCn1wkCH7f4m-L80Ir3gvjw,353
3
3
  version_query/_version.py,sha256=9v7K1pYZdn5R9MWTET31NIH4NlFBK0vec6iAJGg4awQ,120
4
4
  version_query/git_query.py,sha256=koqL0vxAPgYAJK-xmyDmk_FsfODRX6I9SB_Ww2J2wEY,7001
5
+ version_query/local_git_version.py,sha256=M2KPuMZVUDZ1gDmwx3ze6i8G5CX36mmn0U7slj0CP1s,670
5
6
  version_query/main.py,sha256=iP_48b18DmF8NhydPggbzDEnWxBvQedFtJK_MBlxQ8Q,1895
6
7
  version_query/parser.py,sha256=dLZheqfcFMe7pWp-9cIXtrOO4FRlGfO2IJJimM30Y6g,1779
7
8
  version_query/patterns.py,sha256=hvEerv6RhRntHrg_YkOB_njRf-qU3ydyqKPFH3QbzzM,1551
@@ -9,9 +10,9 @@ version_query/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
10
  version_query/py_query.py,sha256=R-gCzbnZzNTuBTdM9lc0Zk24aKQMsUrbHBuqZGlCrNw,3259
10
11
  version_query/query.py,sha256=cwo5mn_XpSVmnwu_BeCN1q-SeokjSxeKo6-SyLefCQE,3090
11
12
  version_query/version.py,sha256=bNWQ5EKux8q-Vs6I6GddCS8TNmsAXtPKOsHz9p_o4ag,24490
12
- version_query-1.6.3.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
13
- version_query-1.6.3.dev0.dist-info/licenses/NOTICE,sha256=Jupai3q5kScVFG65xi42lIj4p-a_ds8R0t2GTGfubnk,670
14
- version_query-1.6.3.dev0.dist-info/METADATA,sha256=k0EHg-Bw98ruJjShxITZKLJFRA9UMMMR5brH3ObAgX4,18085
15
- version_query-1.6.3.dev0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
16
- version_query-1.6.3.dev0.dist-info/top_level.txt,sha256=Sw335Q29h6EUZHfPSji8rGTnBv2osM7_kzDqwJc9l_I,14
17
- version_query-1.6.3.dev0.dist-info/RECORD,,
13
+ version_query-1.7.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
14
+ version_query-1.7.0.dist-info/licenses/NOTICE,sha256=Jupai3q5kScVFG65xi42lIj4p-a_ds8R0t2GTGfubnk,670
15
+ version_query-1.7.0.dist-info/METADATA,sha256=vrQCY7c4ZtQppRxgoFf9YA16rpUJnYwpUNJST5z0yHY,20497
16
+ version_query-1.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ version_query-1.7.0.dist-info/top_level.txt,sha256=Sw335Q29h6EUZHfPSji8rGTnBv2osM7_kzDqwJc9l_I,14
18
+ version_query-1.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5