version-query 1.7.1__tar.gz → 1.8.0rc2__tar.gz

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.
Files changed (38) hide show
  1. {version_query-1.7.1 → version_query-1.8.0rc2}/MANIFEST.in +0 -2
  2. {version_query-1.7.1/version_query.egg-info → version_query-1.8.0rc2}/PKG-INFO +13 -21
  3. {version_query-1.7.1 → version_query-1.8.0rc2}/README.rst +8 -14
  4. version_query-1.8.0rc2/pyproject.toml +87 -0
  5. {version_query-1.7.1 → version_query-1.8.0rc2}/setup.py +2 -3
  6. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/local_git_version.py +2 -2
  7. version_query-1.8.0rc2/version_query/local_version.py +20 -0
  8. version_query-1.8.0rc2/version_query/py_query.py +111 -0
  9. {version_query-1.7.1 → version_query-1.8.0rc2/version_query.egg-info}/PKG-INFO +13 -21
  10. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query.egg-info/SOURCES.txt +2 -2
  11. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query.egg-info/requires.txt +1 -1
  12. version_query-1.7.1/pyproject.toml +0 -46
  13. version_query-1.7.1/requirements.txt +0 -4
  14. version_query-1.7.1/requirements_test.txt +0 -2
  15. version_query-1.7.1/version_query/py_query.py +0 -69
  16. {version_query-1.7.1 → version_query-1.8.0rc2}/LICENSE +0 -0
  17. {version_query-1.7.1 → version_query-1.8.0rc2}/NOTICE +0 -0
  18. {version_query-1.7.1 → version_query-1.8.0rc2}/setup.cfg +0 -0
  19. {version_query-1.7.1 → version_query-1.8.0rc2}/test/__init__.py +0 -0
  20. {version_query-1.7.1 → version_query-1.8.0rc2}/test/examples.py +0 -0
  21. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_cli.py +0 -0
  22. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_git.py +0 -0
  23. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_local_git_version.py +0 -0
  24. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_packaging.py +0 -0
  25. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_query.py +0 -0
  26. {version_query-1.7.1 → version_query-1.8.0rc2}/test/test_version.py +0 -0
  27. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/__init__.py +0 -0
  28. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/__main__.py +0 -0
  29. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/_version.py +0 -0
  30. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/git_query.py +0 -0
  31. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/main.py +0 -0
  32. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/parser.py +0 -0
  33. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/patterns.py +0 -0
  34. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/py.typed +0 -0
  35. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/query.py +0 -0
  36. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query/version.py +0 -0
  37. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query.egg-info/dependency_links.txt +0 -0
  38. {version_query-1.7.1 → version_query-1.8.0rc2}/version_query.egg-info/top_level.txt +0 -0
@@ -1,8 +1,6 @@
1
- include requirements.txt
2
1
  include LICENSE
3
2
  include NOTICE
4
3
  include ./*/py.typed
5
4
 
6
- include requirements_test.txt
7
5
  recursive-include ./test __init__.py
8
6
  include test/examples.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: version-query
3
- Version: 1.7.1
3
+ Version: 1.8.0rc2
4
4
  Summary: Zero-overhead package versioning for Python.
5
5
  Home-page: https://github.com/mbdevpl/version-query
6
6
  Download-URL:
@@ -35,19 +35,17 @@ License-File: NOTICE
35
35
  Requires-Dist: boilerplates[cli,logging]~=1.2
36
36
  Requires-Dist: GitPython~=3.1
37
37
  Requires-Dist: packaging>=24.0
38
- Requires-Dist: semver<3.1,>=2.13
38
+ Requires-Dist: semver<3.2,>=2.13
39
39
  Dynamic: author
40
40
  Dynamic: author-email
41
41
  Dynamic: classifier
42
42
  Dynamic: description
43
43
  Dynamic: description-content-type
44
44
  Dynamic: home-page
45
- Dynamic: keywords
46
45
  Dynamic: license-file
47
46
  Dynamic: license-expression
48
47
  Dynamic: maintainer
49
48
  Dynamic: maintainer-email
50
- Dynamic: requires-dist
51
49
  Dynamic: requires-python
52
50
  Dynamic: summary
53
51
 
@@ -68,7 +66,7 @@ Zero-overhead package versioning for Python.
68
66
  :target: https://pypi.org/project/version-query
69
67
  :alt: package version from PyPI
70
68
 
71
- .. image:: https://github.com/mbdevpl/version-query/actions/workflows/python.yml/badge.svg?branch=main
69
+ .. image:: https://github.com/mbdevpl/version-query/actions/workflows/test.yml/badge.svg?branch=main
72
70
  :target: https://github.com/mbdevpl/version-query/actions
73
71
  :alt: build status from GitHub
74
72
 
@@ -81,7 +79,7 @@ Zero-overhead package versioning for Python.
81
79
  :alt: grade from Codacy
82
80
 
83
81
  .. image:: https://img.shields.io/github/license/mbdevpl/version-query.svg
84
- :target: https://github.com/mbdevpl/version-query/blob/v1.7.1/NOTICE
82
+ :target: https://github.com/mbdevpl/version-query/blob/vNone/NOTICE
85
83
  :alt: license
86
84
 
87
85
  Package versioning toolkit for Python which relies on git tags, git history traversal
@@ -199,25 +197,19 @@ One of such packages is setuptools. When using it, one can do the following:
199
197
  .. code:: toml
200
198
 
201
199
  [project]
202
- dynamic = ["version"]
200
+ dynamic = ['version']
203
201
  ...
204
202
 
205
203
  [build-system]
206
- requires = ["setuptools >= 70.0"]
207
- build-backend = "setuptools.build_meta"
204
+ requires = ['setuptools >= 70.0']
205
+ build-backend = 'setuptools.build_meta'
208
206
 
209
207
  [tool.setuptools.dynamic]
210
- version = {attr = "version_query.local_git_version.PREDICTED"}
208
+ version = {attr = 'version_query.local_version.PREDICTED'}
211
209
 
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
210
+ There's also an option to use ``version_query.local_git_version.PREDICTED``, however that depends
211
+ on the build happening in a Git repository, and depending on how you build your package,
212
+ the build system may copy files to a temporary folder which is not a repository.
221
213
 
222
214
  Versioning scheme
223
215
  =================
@@ -572,8 +564,8 @@ Requirements
572
564
 
573
565
  Python version 3.10 or later.
574
566
 
575
- Python libraries as specified in `requirements.txt <https://github.com/mbdevpl/version-query/blob/v1.7.1/requirements.txt>`_.
567
+ Python libraries as specified in `<requirements.txt>`_.
576
568
 
577
- Building and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/version-query/blob/v1.7.1/requirements_test.txt>`_.
569
+ Building and running tests additionally requires packages listed in `<requirements_test.txt>`_.
578
570
 
579
571
  Tested on Linux, macOS and Windows.
@@ -15,7 +15,7 @@ Zero-overhead package versioning for Python.
15
15
  :target: https://pypi.org/project/version-query
16
16
  :alt: package version from PyPI
17
17
 
18
- .. image:: https://github.com/mbdevpl/version-query/actions/workflows/python.yml/badge.svg?branch=main
18
+ .. image:: https://github.com/mbdevpl/version-query/actions/workflows/test.yml/badge.svg?branch=main
19
19
  :target: https://github.com/mbdevpl/version-query/actions
20
20
  :alt: build status from GitHub
21
21
 
@@ -146,25 +146,19 @@ One of such packages is setuptools. When using it, one can do the following:
146
146
  .. code:: toml
147
147
 
148
148
  [project]
149
- dynamic = ["version"]
149
+ dynamic = ['version']
150
150
  ...
151
151
 
152
152
  [build-system]
153
- requires = ["setuptools >= 70.0"]
154
- build-backend = "setuptools.build_meta"
153
+ requires = ['setuptools >= 70.0']
154
+ build-backend = 'setuptools.build_meta'
155
155
 
156
156
  [tool.setuptools.dynamic]
157
- version = {attr = "version_query.local_git_version.PREDICTED"}
157
+ version = {attr = 'version_query.local_version.PREDICTED'}
158
158
 
159
- Depending on how you build your package, the build system may copy files to a temporary folder
160
- when building. In such case, you need to set ``PROJECT_FOLDER`` environment variable
161
- to the current working directory before running the build command.
162
-
163
- For example, when using ``build`` package:
164
-
165
- .. code:: bash
166
-
167
- PROJECT_FOLDER=$(pwd) python3 -m build
159
+ There's also an option to use ``version_query.local_git_version.PREDICTED``, however that depends
160
+ on the build happening in a Git repository, and depending on how you build your package,
161
+ the build system may copy files to a temporary folder which is not a repository.
168
162
 
169
163
  Versioning scheme
170
164
  =================
@@ -0,0 +1,87 @@
1
+ [project]
2
+ name = 'version-query'
3
+ requires-python = '>=3.10,<4'
4
+ keywords = [
5
+ 'automation', 'continuous integration', 'git', 'releasing', 'semantic versioning',
6
+ 'tagging', 'versioning'
7
+ ]
8
+ dependencies = [
9
+ 'boilerplates[cli,logging] ~= 1.2',
10
+ 'GitPython ~= 3.1',
11
+ 'packaging >= 24.0',
12
+ 'semver >= 2.13, < 3.2'
13
+ ]
14
+ dynamic = ['authors', 'classifiers', 'description', 'license', 'maintainers', 'readme', 'version']
15
+
16
+ [dependency-groups]
17
+ flake518 = [
18
+ 'flake518~=1.6'
19
+ ]
20
+ mypy = [
21
+ 'mypy~=2.4',
22
+ 'types-setuptools>=67.4'
23
+ ]
24
+ publish = [
25
+ 'build~=1.6',
26
+ 'twine~=7.0'
27
+ ]
28
+ pydocstyle = [
29
+ 'pydocstyle~=6.3'
30
+ ]
31
+ pylint = [
32
+ 'pylint~=4.1'
33
+ ]
34
+ test = [
35
+ 'boilerplates[git-repo-tests,packaging-tests]~=1.2',
36
+ 'codecov~=2.1',
37
+ 'coverage~=7.2'
38
+ ]
39
+
40
+ [build-system]
41
+ build-backend = 'setuptools.build_meta'
42
+ requires = [
43
+ 'boilerplates[setup] ~= 1.2',
44
+ 'version-query ~= 1.6'
45
+ ]
46
+
47
+ [tool.setuptools.dynamic]
48
+ version = {attr = 'version_query.local_version.PREDICTED'}
49
+
50
+ [tool.flake8]
51
+ max-line-length = 100
52
+ max-doc-length = 100
53
+
54
+ [[tool.mypy.overrides]]
55
+ module = [
56
+ 'semver'
57
+ ]
58
+ ignore_missing_imports = true
59
+
60
+ [tool.pydocstyle]
61
+ ignore = [
62
+ 'D102', 'D103', 'D105', 'D107',
63
+ 'D203', 'D213',
64
+ 'D406', 'D407', 'D412', 'D413'
65
+ ]
66
+
67
+ [tool.pylint.MASTER]
68
+ load-plugins = [
69
+ 'pylint.extensions.broad_try_clause',
70
+ 'pylint.extensions.mccabe',
71
+ 'pylint.extensions.no_self_use',
72
+ 'pylint.extensions.redefined_variable_type'
73
+ ]
74
+
75
+ [tool.pylint.'MESSAGES CONTROL']
76
+ docstring-min-length = 5
77
+
78
+ [tool.pylint.SIMILARITIES]
79
+ ignore-imports = 'yes'
80
+ min-similarity-lines = 5
81
+
82
+ [tool.pylint.BASIC]
83
+ no-docstring-rgx = '^(test)?_|.*Tests$'
84
+ unsafe-load-any-extension = 'yes'
85
+
86
+ [tool.pylint.REPORTS]
87
+ output-format = 'colorized'
@@ -30,9 +30,8 @@ class Package(boilerplates.setup.Package):
30
30
  'Topic :: System :: Software Distribution',
31
31
  'Topic :: Utilities',
32
32
  'Typing :: Typed']
33
- keywords = [
34
- 'automation', 'continuous integration', 'git', 'releasing', 'semantic versioning',
35
- 'tagging', 'versioning']
33
+ version = None
34
+ install_requires = []
36
35
 
37
36
 
38
37
  if __name__ == '__main__':
@@ -4,11 +4,11 @@ For example, when using setuptools in pyproject.toml,
4
4
  one can set the version dynamically as follows:
5
5
 
6
6
  [project]
7
- dynamic = ["version"]
7
+ dynamic = ['version']
8
8
  ...
9
9
 
10
10
  [tool.setuptools.dynamic]
11
- version = {attr = "version_query.local_git_version.PREDICTED"}
11
+ version = {attr = 'version_query.local_git_version.PREDICTED'}
12
12
  """
13
13
 
14
14
  import os
@@ -0,0 +1,20 @@
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_version.PREDICTED'}
12
+ """
13
+
14
+ import pathlib
15
+
16
+ from .query import query_folder, predict_folder
17
+
18
+ _CURRENT_FOLDER: pathlib.Path = pathlib.Path()
19
+ QUERIED: str = query_folder(_CURRENT_FOLDER).to_str()
20
+ PREDICTED: str = predict_folder(_CURRENT_FOLDER).to_str()
@@ -0,0 +1,111 @@
1
+ """Python package version query tools."""
2
+
3
+ import logging
4
+ import json
5
+ import pathlib
6
+
7
+ from .version import Version
8
+
9
+ _LOG = logging.getLogger(__name__)
10
+
11
+
12
+ def query_metadata_json(path: pathlib.Path) -> Version:
13
+ """Get version from metadata.json file."""
14
+ with path.open('r') as metadata_file:
15
+ metadata = json.load(metadata_file)
16
+ version_str = metadata['version']
17
+ return Version.from_str(version_str)
18
+
19
+
20
+ def query_pkg_info(path: pathlib.Path) -> Version:
21
+ """Get version from PKG-INFO file."""
22
+ with path.open('r') as pkginfo_file:
23
+ for line in pkginfo_file:
24
+ if line.startswith('Version:'):
25
+ version_str = line.replace('Version:', '').strip()
26
+ return Version.from_str(version_str)
27
+ raise ValueError(path)
28
+
29
+
30
+ def _pick_metadata_json_path(*metadata_json_paths: pathlib.Path) -> pathlib.Path | None:
31
+ if not metadata_json_paths:
32
+ return None
33
+ if len(metadata_json_paths) == 1:
34
+ return metadata_json_paths[0]
35
+ versions = []
36
+ for path in metadata_json_paths:
37
+ versions.append(query_metadata_json(path))
38
+ if all(v == versions[0] for v in versions[1:]):
39
+ return metadata_json_paths[0]
40
+ _LOG.warning(
41
+ 'found differing versions in provided JSON metadata files %s: %s',
42
+ metadata_json_paths, versions)
43
+ return None
44
+
45
+
46
+ def _pick_pkg_info_path(*pkg_info_paths: pathlib.Path) -> pathlib.Path | None:
47
+ if not pkg_info_paths:
48
+ return None
49
+ if len(pkg_info_paths) == 1:
50
+ return pkg_info_paths[0]
51
+ versions = []
52
+ for path in pkg_info_paths:
53
+ versions.append(query_pkg_info(path))
54
+ if all(v == versions[0] for v in versions[1:]):
55
+ return pkg_info_paths[0]
56
+ _LOG.warning(
57
+ 'found differing versions in provided PKG-INFO files %s: %s',
58
+ pkg_info_paths, versions)
59
+ return None
60
+
61
+
62
+ def query_package_folder(path: pathlib.Path, search_parent_directories: bool = False) -> Version:
63
+ """Get version from Python package folder."""
64
+ global_metadata_json_paths, global_pkg_info_paths = [], []
65
+ if path.joinpath('pyproject.toml').exists() or path.joinpath('setup.py').exists():
66
+ metadata_json_paths = [*path.glob('metadata.json'), *path.glob('*.dist-info/metadata.json')]
67
+ metadata_json_path = _pick_metadata_json_path(*metadata_json_paths)
68
+ pkg_info_paths = [
69
+ *path.glob('PKG-INFO'), *path.glob('*.egg-info/PKG-INFO'),
70
+ *path.glob('METADATA'), *path.glob('*.dist-info/METADATA')]
71
+ pkg_info_path = _pick_pkg_info_path(*pkg_info_paths)
72
+ if metadata_json_path is not None and pkg_info_path is None:
73
+ return query_metadata_json(metadata_json_path)
74
+ if metadata_json_path is None and pkg_info_path is not None:
75
+ return query_pkg_info(pkg_info_path)
76
+ _LOG.debug(
77
+ 'in %s found pyproject.toml or setup.py, as well as'
78
+ ' %i JSON metadata: %s and %i PKG-INFO metadata: %s'
79
+ ' - unable to infer package metadata, continuing search',
80
+ path, len(metadata_json_paths), metadata_json_paths, len(pkg_info_paths),
81
+ pkg_info_paths)
82
+ global_metadata_json_paths.extend(metadata_json_paths)
83
+ global_pkg_info_paths.extend(pkg_info_paths)
84
+ paths = [path]
85
+ if search_parent_directories:
86
+ paths += path.parents
87
+ for pth in paths:
88
+ metadata_json_paths = [
89
+ *pth.parent.glob(f'{pth.name}.dist-info/metadata.json'),
90
+ *pth.parent.glob(f'{pth.name}-*.dist-info/metadata.json')]
91
+ metadata_json_path = _pick_metadata_json_path(*metadata_json_paths)
92
+ pkg_info_paths = [
93
+ *pth.parent.glob(f'{pth.name}.egg-info/PKG-INFO'),
94
+ *pth.parent.glob(f'{pth.name}-*.egg-info/PKG-INFO'),
95
+ *pth.parent.glob(f'{pth.name}.dist-info/METADATA'),
96
+ *pth.parent.glob(f'{pth.name}-*.dist-info/METADATA')]
97
+ pkg_info_path = _pick_pkg_info_path(*pkg_info_paths)
98
+ if metadata_json_path is not None and pkg_info_path is None:
99
+ return query_metadata_json(metadata_json_path)
100
+ if metadata_json_path is None and pkg_info_path is not None:
101
+ return query_pkg_info(pkg_info_path)
102
+ _LOG.debug(
103
+ 'in %s found %i JSON metadata: %s and %i PKG-INFO metadata: %s'
104
+ ' - unable to infer package metadata, continuing search',
105
+ pth, len(metadata_json_paths), metadata_json_paths, len(pkg_info_paths), pkg_info_paths)
106
+ global_metadata_json_paths.extend(metadata_json_paths)
107
+ global_pkg_info_paths.extend(pkg_info_paths)
108
+ raise ValueError(
109
+ f'unable to infer package metadata from the following paths {paths} '
110
+ f'- found {len(global_metadata_json_paths)} JSON metadata: {global_metadata_json_paths}'
111
+ f' and {len(global_pkg_info_paths)} PKG-INFO metadata: {global_pkg_info_paths}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: version-query
3
- Version: 1.7.1
3
+ Version: 1.8.0rc2
4
4
  Summary: Zero-overhead package versioning for Python.
5
5
  Home-page: https://github.com/mbdevpl/version-query
6
6
  Download-URL:
@@ -35,19 +35,17 @@ License-File: NOTICE
35
35
  Requires-Dist: boilerplates[cli,logging]~=1.2
36
36
  Requires-Dist: GitPython~=3.1
37
37
  Requires-Dist: packaging>=24.0
38
- Requires-Dist: semver<3.1,>=2.13
38
+ Requires-Dist: semver<3.2,>=2.13
39
39
  Dynamic: author
40
40
  Dynamic: author-email
41
41
  Dynamic: classifier
42
42
  Dynamic: description
43
43
  Dynamic: description-content-type
44
44
  Dynamic: home-page
45
- Dynamic: keywords
46
45
  Dynamic: license-file
47
46
  Dynamic: license-expression
48
47
  Dynamic: maintainer
49
48
  Dynamic: maintainer-email
50
- Dynamic: requires-dist
51
49
  Dynamic: requires-python
52
50
  Dynamic: summary
53
51
 
@@ -68,7 +66,7 @@ Zero-overhead package versioning for Python.
68
66
  :target: https://pypi.org/project/version-query
69
67
  :alt: package version from PyPI
70
68
 
71
- .. image:: https://github.com/mbdevpl/version-query/actions/workflows/python.yml/badge.svg?branch=main
69
+ .. image:: https://github.com/mbdevpl/version-query/actions/workflows/test.yml/badge.svg?branch=main
72
70
  :target: https://github.com/mbdevpl/version-query/actions
73
71
  :alt: build status from GitHub
74
72
 
@@ -81,7 +79,7 @@ Zero-overhead package versioning for Python.
81
79
  :alt: grade from Codacy
82
80
 
83
81
  .. image:: https://img.shields.io/github/license/mbdevpl/version-query.svg
84
- :target: https://github.com/mbdevpl/version-query/blob/v1.7.1/NOTICE
82
+ :target: https://github.com/mbdevpl/version-query/blob/vNone/NOTICE
85
83
  :alt: license
86
84
 
87
85
  Package versioning toolkit for Python which relies on git tags, git history traversal
@@ -199,25 +197,19 @@ One of such packages is setuptools. When using it, one can do the following:
199
197
  .. code:: toml
200
198
 
201
199
  [project]
202
- dynamic = ["version"]
200
+ dynamic = ['version']
203
201
  ...
204
202
 
205
203
  [build-system]
206
- requires = ["setuptools >= 70.0"]
207
- build-backend = "setuptools.build_meta"
204
+ requires = ['setuptools >= 70.0']
205
+ build-backend = 'setuptools.build_meta'
208
206
 
209
207
  [tool.setuptools.dynamic]
210
- version = {attr = "version_query.local_git_version.PREDICTED"}
208
+ version = {attr = 'version_query.local_version.PREDICTED'}
211
209
 
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
210
+ There's also an option to use ``version_query.local_git_version.PREDICTED``, however that depends
211
+ on the build happening in a Git repository, and depending on how you build your package,
212
+ the build system may copy files to a temporary folder which is not a repository.
221
213
 
222
214
  Versioning scheme
223
215
  =================
@@ -572,8 +564,8 @@ Requirements
572
564
 
573
565
  Python version 3.10 or later.
574
566
 
575
- Python libraries as specified in `requirements.txt <https://github.com/mbdevpl/version-query/blob/v1.7.1/requirements.txt>`_.
567
+ Python libraries as specified in `<requirements.txt>`_.
576
568
 
577
- Building and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/version-query/blob/v1.7.1/requirements_test.txt>`_.
569
+ Building and running tests additionally requires packages listed in `<requirements_test.txt>`_.
578
570
 
579
571
  Tested on Linux, macOS and Windows.
@@ -3,8 +3,6 @@ MANIFEST.in
3
3
  NOTICE
4
4
  README.rst
5
5
  pyproject.toml
6
- requirements.txt
7
- requirements_test.txt
8
6
  setup.py
9
7
  ./test/__init__.py
10
8
  ./test/examples.py
@@ -19,6 +17,7 @@ setup.py
19
17
  ./version_query/_version.py
20
18
  ./version_query/git_query.py
21
19
  ./version_query/local_git_version.py
20
+ ./version_query/local_version.py
22
21
  ./version_query/main.py
23
22
  ./version_query/parser.py
24
23
  ./version_query/patterns.py
@@ -39,6 +38,7 @@ version_query/__main__.py
39
38
  version_query/_version.py
40
39
  version_query/git_query.py
41
40
  version_query/local_git_version.py
41
+ version_query/local_version.py
42
42
  version_query/main.py
43
43
  version_query/parser.py
44
44
  version_query/patterns.py
@@ -1,4 +1,4 @@
1
1
  boilerplates[cli,logging]~=1.2
2
2
  GitPython~=3.1
3
3
  packaging>=24.0
4
- semver<3.1,>=2.13
4
+ semver<3.2,>=2.13
@@ -1,46 +0,0 @@
1
- [build-system]
2
- requires = [
3
- 'boilerplates[setup] ~= 1.2',
4
- 'GitPython ~= 3.1',
5
- 'packaging >= 24.0',
6
- 'semver >= 2.13, < 3.1'
7
- ]
8
-
9
- [tool.flake8]
10
- max-line-length = 100
11
- max-doc-length = 100
12
-
13
- [[tool.mypy.overrides]]
14
- module = [
15
- 'semver'
16
- ]
17
- ignore_missing_imports = true
18
-
19
- [tool.pydocstyle]
20
- ignore = [
21
- 'D102', 'D103', 'D105', 'D107',
22
- 'D203', 'D213',
23
- 'D406', 'D407', 'D412', 'D413'
24
- ]
25
-
26
- [tool.pylint.MASTER]
27
- load-plugins = [
28
- 'pylint.extensions.broad_try_clause',
29
- 'pylint.extensions.mccabe',
30
- 'pylint.extensions.no_self_use',
31
- 'pylint.extensions.redefined_variable_type'
32
- ]
33
-
34
- [tool.pylint.'MESSAGES CONTROL']
35
- docstring-min-length = 5
36
-
37
- [tool.pylint.SIMILARITIES]
38
- ignore-imports = 'yes'
39
- min-similarity-lines = 5
40
-
41
- [tool.pylint.BASIC]
42
- no-docstring-rgx = '^(test)?_|.*Tests$'
43
- unsafe-load-any-extension = 'yes'
44
-
45
- [tool.pylint.REPORTS]
46
- output-format = 'colorized'
@@ -1,4 +0,0 @@
1
- boilerplates[cli,logging] ~= 1.2
2
- GitPython ~= 3.1
3
- packaging >= 24.0
4
- semver >= 2.13, < 3.1
@@ -1,2 +0,0 @@
1
- -r requirements.txt
2
- boilerplates[git-repo-tests,packaging-tests] ~= 1.2
@@ -1,69 +0,0 @@
1
- """Python package version query tools."""
2
-
3
- import logging
4
- import json
5
- import pathlib
6
-
7
- from .version import Version
8
-
9
- _LOG = logging.getLogger(__name__)
10
-
11
-
12
- def query_metadata_json(path: pathlib.Path) -> Version:
13
- """Get version from metadata.json file."""
14
- with path.open('r') as metadata_file:
15
- metadata = json.load(metadata_file)
16
- version_str = metadata['version']
17
- return Version.from_str(version_str)
18
-
19
-
20
- def query_pkg_info(path: pathlib.Path) -> Version:
21
- """Get version from PKG-INFO file."""
22
- with path.open('r') as pkginfo_file:
23
- for line in pkginfo_file:
24
- if line.startswith('Version:'):
25
- version_str = line.replace('Version:', '').strip()
26
- return Version.from_str(version_str)
27
- raise ValueError(path)
28
-
29
-
30
- def query_package_folder(path: pathlib.Path, search_parent_directories: bool = False) -> Version:
31
- """Get version from Python package folder."""
32
- global_metadata_json_paths, global_pkg_info_paths = [], []
33
- if path.joinpath('pyproject.toml').exists() or path.joinpath('setup.py').exists():
34
- metadata_json_paths = list(path.glob('*.dist-info/metadata.json'))
35
- pkg_info_paths = list(path.glob('*.egg-info/PKG-INFO'))
36
- pkg_info_paths += list(path.glob('*.dist-info/METADATA'))
37
- if len(metadata_json_paths) == 1 and not pkg_info_paths:
38
- return query_metadata_json(metadata_json_paths[0])
39
- if not metadata_json_paths and len(pkg_info_paths) == 1:
40
- return query_pkg_info(pkg_info_paths[0])
41
- _LOG.debug(
42
- 'in %s found pyproject.toml or setup.py, as well as'
43
- ' %i JSON metadata: %s and %i PKG-INFO metadata: %s'
44
- ' - unable to infer package metadata, continuing search',
45
- path, len(metadata_json_paths), metadata_json_paths, len(pkg_info_paths),
46
- pkg_info_paths)
47
- global_metadata_json_paths.extend(metadata_json_paths)
48
- global_pkg_info_paths.extend(pkg_info_paths)
49
- paths = [path]
50
- if search_parent_directories:
51
- paths += path.parents
52
- for pth in paths:
53
- metadata_json_paths = list(pth.parent.glob(f'{pth.name}*.dist-info/metadata.json'))
54
- pkg_info_paths = list(pth.parent.glob(f'{pth.name}*.egg-info/PKG-INFO'))
55
- pkg_info_paths += list(pth.parent.glob(f'{pth.name}*.dist-info/METADATA'))
56
- if len(metadata_json_paths) == 1 and not pkg_info_paths:
57
- return query_metadata_json(metadata_json_paths[0])
58
- if not metadata_json_paths and len(pkg_info_paths) == 1:
59
- return query_pkg_info(pkg_info_paths[0])
60
- _LOG.debug(
61
- 'in %s found %i JSON metadata: %s and %i PKG-INFO metadata: %s'
62
- ' - unable to infer package metadata, continuing search',
63
- pth, len(metadata_json_paths), metadata_json_paths, len(pkg_info_paths), pkg_info_paths)
64
- global_metadata_json_paths.extend(metadata_json_paths)
65
- global_pkg_info_paths.extend(pkg_info_paths)
66
- raise ValueError(
67
- f'unable to infer package metadata from the following paths {paths} '
68
- f'- found {len(global_metadata_json_paths)} JSON metadata: {global_metadata_json_paths}'
69
- f' and {len(global_pkg_info_paths)} PKG-INFO metadata: {global_pkg_info_paths}')
File without changes
File without changes