utils-mystuff 1.2.0__tar.gz → 1.2.1__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.
@@ -1,3 +1,4 @@
1
1
  # Contributors
2
2
 
3
3
  * [dornech](https://github.com/dornech)
4
+ * [maresb](https://github.com/maresb)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: utils-mystuff
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: Package with various utilities i.e. VB regex translation, CLI logging, file handling, basic GUI wrapper ...
5
5
  Project-URL: Documentation, https://dornech.github.io/utils-mystuff
6
6
  Project-URL: Source, https://github.com/dornech/utils-mystuff
@@ -20,11 +20,12 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: easygui
22
22
  Requires-Dist: freesimplegui
23
- Requires-Dist: hatchling
24
23
  Requires-Dist: pymsgbox
25
24
  Requires-Dist: python-dateutil
26
25
  Requires-Dist: pytz
27
- Requires-Dist: utils-mystuff
26
+ Provides-Extra: vcs-version
27
+ Requires-Dist: hatch-vcs; extra == 'vcs-version'
28
+ Requires-Dist: hatchling; extra == 'vcs-version'
28
29
  Description-Content-Type: text/markdown
29
30
 
30
31
  # Personal utilities package for Python
@@ -47,6 +48,10 @@ method stubs (at least for most important subroutines) as a compromise.
47
48
 
48
49
  ## Development
49
50
 
51
+ `utils_mystuff.__version__` reads the version recorded at installation. To have an editable
52
+ installation follow new Git tags without reinstalling, run `python -m pip install -e '.[vcs-version]'`
53
+ in the checkout and set `UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION=1` in that development environment.
54
+
50
55
  To set up [hatch] and [pre-commit] for the first time:
51
56
 
52
57
  1. install [hatch] globally, e.g. with [pipx], i.e. `pipx install hatch`,
@@ -18,6 +18,10 @@ method stubs (at least for most important subroutines) as a compromise.
18
18
 
19
19
  ## Development
20
20
 
21
+ `utils_mystuff.__version__` reads the version recorded at installation. To have an editable
22
+ installation follow new Git tags without reinstalling, run `python -m pip install -e '.[vcs-version]'`
23
+ in the checkout and set `UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION=1` in that development environment.
24
+
21
25
  To set up [hatch] and [pre-commit] for the first time:
22
26
 
23
27
  1. install [hatch] globally, e.g. with [pipx], i.e. `pipx install hatch`,
@@ -41,16 +41,14 @@ classifiers = [
41
41
  dependencies = [
42
42
  "easygui",
43
43
  "FreeSimpleGUI",
44
- "hatchling",
45
44
  "python-dateutil",
46
45
  "pytz",
47
46
  "pymsgbox",
48
- "utils-mystuff",
49
47
  ]
50
48
  dynamic = ["version"]
51
49
 
52
50
  [project.optional-dependencies]
53
- # n. a.
51
+ vcs-version = ["hatchling", "hatch-vcs"]
54
52
 
55
53
  [project.scripts]
56
54
  # n. a.
@@ -93,7 +91,7 @@ exclude = [
93
91
  [tool.commitizen]
94
92
  name = "cz_customize"
95
93
  version_scheme = "pep440"
96
- version = "1.2.0"
94
+ version = "1.2.1"
97
95
  version_files = ["pyproject.toml:version"]
98
96
  tag_format = "v$version"
99
97
  # retry_after_failure = false
@@ -262,7 +260,8 @@ pymsgbox = "pymsgbox"
262
260
  python-dateutil = "dateutil"
263
261
 
264
262
  [tool.deptry.per_rule_ignores]
265
- DEP002 = ["easygui", "FreeSimpleGUI", "pymsgbox"]
263
+ # hatch-vcs is loaded through Hatchling's version source entry point.
264
+ DEP002 = ["easygui", "FreeSimpleGUI", "pymsgbox", "hatch-vcs"]
266
265
 
267
266
  [tool.cruft]
268
267
  skip = ["README.md", "CHANGELOG.MD", "src/", "tests/", "docs/", "notebooks/"]
@@ -326,6 +325,7 @@ dependencies = [
326
325
  # Hatch default test environment for "hatch test" (also used in GitHub Action)
327
326
  # do not define scripts [tool.hatch.envs.hatch-test.scripts] without taking over hatch standard scripts!!!
328
327
  [tool.hatch.envs.hatch-test]
328
+ features = ["vcs-version"]
329
329
  dependencies = [
330
330
  "pip",
331
331
  "coverage-enable-subprocess==1.0",
@@ -339,6 +339,7 @@ dependencies = [
339
339
 
340
340
  # Hatch local testing environment with test-only dependencies (do not mix up with default hatch-test environment "hatch-test" !)
341
341
  [tool.hatch.envs.test]
342
+ features = ["vcs-version"]
342
343
  dependencies = [
343
344
  # required test dependencies
344
345
  "pip",
@@ -0,0 +1,44 @@
1
+ """Read the installed version, with optional VCS lookup for editable installs.
2
+
3
+ Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
4
+ """
5
+
6
+
7
+ # ruff and mypy per file settings
8
+ # others
9
+ # ruff: noqa: E303, RUF105
10
+
11
+ # fmt: off
12
+
13
+
14
+
15
+ import os
16
+ from contextlib import chdir
17
+ from importlib.metadata import version
18
+ from pathlib import Path
19
+
20
+
21
+
22
+ def _get_hatch_version():
23
+ """Read the checkout's version using Hatch and its configured version source."""
24
+
25
+ from hatchling.metadata.core import ProjectMetadata # ruff: ignore[import-outside-top-level]
26
+ from hatchling.plugin.manager import PluginManager # ruff: ignore[import-outside-top-level]
27
+ from hatchling.utils.fs import locate_file # ruff: ignore[import-outside-top-level]
28
+
29
+ pyproject_toml = locate_file(__file__, "pyproject.toml")
30
+ if pyproject_toml is None:
31
+ msg = "UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION requires a utils-mystuff source checkout"
32
+ raise RuntimeError(msg)
33
+
34
+ # Hatch metadata hooks expect to run from the project root.
35
+ root = Path(pyproject_toml).parent
36
+ with chdir(root):
37
+ metadata = ProjectMetadata(root=str(root), plugin_manager=PluginManager())
38
+ return metadata.core.version or metadata.hatch.version.cached
39
+
40
+
41
+ if os.environ.get("UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION"):
42
+ __version__ = _get_hatch_version()
43
+ else:
44
+ __version__ = version("utils-mystuff")
@@ -1,65 +0,0 @@
1
- """Compute the version number and store it in the `__version__` variable.
2
-
3
- Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
4
- """
5
-
6
-
7
- # ruff and mypy per file settings
8
- # others
9
- # ruff: noqa: E302, PLC0415, RUF105
10
-
11
- # fmt: off
12
-
13
-
14
- def _get_hatch_version():
15
- """Compute the most up-to-date version number in a development environment.
16
-
17
- For more details, see <https://github.com/maresb/hatch-vcs-footgun-example/>.
18
- """
19
- import os
20
- # preparation for Pathlib
21
- # from pathlib import path
22
-
23
- try:
24
- from hatchling.metadata.core import ProjectMetadata
25
- from hatchling.plugin.manager import PluginManager
26
- from hatchling.utils.fs import locate_file
27
- except ImportError:
28
- # Hatchling is not installed, so probably we are not in a development environment.
29
- return None
30
-
31
- pyproject_toml = locate_file(__file__, "pyproject.toml")
32
- if pyproject_toml is None:
33
- err_msg = "pyproject.toml not found although hatchling is installed"
34
- raise RuntimeError(err_msg)
35
- root = os.path.dirname(pyproject_toml)
36
- # preparation for Pathlib
37
- # root = Path(pyproject_toml).parent
38
- # Temporarily set cwd to project root for PEP 517 compliance.
39
- old_cwd = os.getcwd()
40
- # preparation for Pathlib
41
- # old_cwd = Path.cwd()
42
- os.chdir(root)
43
- try:
44
- metadata = ProjectMetadata(root=str(root), plugin_manager=PluginManager())
45
- # Version can be static in pyproject.toml or computed dynamically:
46
- return metadata.core.version or metadata.hatch.version.cached
47
- finally:
48
- os.chdir(old_cwd)
49
-
50
-
51
- def _get_importlib_metadata_version():
52
- """Compute the version number using importlib.metadata.
53
-
54
- This is the official Pythonic way to get the version number of an installed
55
- package. However, it is only updated when a package is installed. Thus, if a
56
- package is installed in editable mode, and a different version is checked out,
57
- then the version number will not be updated.
58
- """
59
- from importlib.metadata import version
60
-
61
- __version__ = version(__package__)
62
- return __version__
63
-
64
-
65
- __version__ = _get_hatch_version() or _get_importlib_metadata_version()
File without changes
File without changes