utils-mystuff 1.1.0__tar.gz → 1.2.0__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.
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/PKG-INFO +6 -7
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/pyproject.toml +55 -31
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/convert_regex.py +1 -1
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/logger_CLI.py +1 -1
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/utils_GUI.py +1 -1
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/utils_filehandling.py +61 -3
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/utils_various.py +2 -7
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/version.py +16 -6
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/.gitignore +0 -0
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/AUTHORS.md +0 -0
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/LICENSE.txt +0 -0
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/README.md +0 -0
- {utils_mystuff-1.1.0 → utils_mystuff-1.2.0}/utils_mystuff/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: utils-mystuff
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
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
|
|
@@ -10,22 +10,21 @@ Author-email: dornech <dornech@gmx.de>
|
|
|
10
10
|
License: GPL-3.0-only
|
|
11
11
|
License-File: AUTHORS.md
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
|
-
Keywords: CLI logging,GUI wrapper,RegEx conversion,command line interface,file handling,logging,regular expression
|
|
13
|
+
Keywords: CLI logging,GUI wrapper,RegEx conversion,command line interface,config file reader,config parser,file handling,logger creartion,logging,regular expression
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
19
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.11
|
|
22
21
|
Requires-Dist: easygui
|
|
23
22
|
Requires-Dist: freesimplegui
|
|
23
|
+
Requires-Dist: hatchling
|
|
24
24
|
Requires-Dist: pymsgbox
|
|
25
25
|
Requires-Dist: python-dateutil
|
|
26
26
|
Requires-Dist: pytz
|
|
27
|
-
|
|
28
|
-
Requires-Dist: typing-extensions; extra == 'python39'
|
|
27
|
+
Requires-Dist: utils-mystuff
|
|
29
28
|
Description-Content-Type: text/markdown
|
|
30
29
|
|
|
31
30
|
# Personal utilities package for Python
|
|
@@ -15,14 +15,15 @@ build-backend = "hatchling.build"
|
|
|
15
15
|
name = "utils-mystuff"
|
|
16
16
|
description = "Package with various utilities i.e. VB regex translation, CLI logging, file handling, basic GUI wrapper ..."
|
|
17
17
|
readme = "README.md"
|
|
18
|
-
requires-python = ">=3.
|
|
18
|
+
requires-python = ">=3.11"
|
|
19
19
|
# only license identifier from https://spdx.org/licenses/ are allowed
|
|
20
20
|
license = { text = "GPL-3.0-only" }
|
|
21
21
|
# keywords for easier look-up on PyPI
|
|
22
22
|
keywords = [
|
|
23
23
|
"RegEx conversion", "regular expression",
|
|
24
|
-
"command line interface", "CLI logging", "logging",
|
|
25
|
-
"
|
|
24
|
+
"command line interface", "CLI logging", "logging", "logger creartion",
|
|
25
|
+
"config file reader", "config parser",
|
|
26
|
+
"GUI wrapper", "file handling",
|
|
26
27
|
]
|
|
27
28
|
authors = [
|
|
28
29
|
{ name = "dornech", email = "dornech@gmx.de" },
|
|
@@ -30,7 +31,6 @@ authors = [
|
|
|
30
31
|
# options under https://pypi.org/classifiers/
|
|
31
32
|
classifiers = [
|
|
32
33
|
"Programming Language :: Python",
|
|
33
|
-
"Programming Language :: Python :: 3.10",
|
|
34
34
|
"Programming Language :: Python :: 3.11",
|
|
35
35
|
"Programming Language :: Python :: 3.12",
|
|
36
36
|
"Programming Language :: Python :: 3.13",
|
|
@@ -40,17 +40,17 @@ classifiers = [
|
|
|
40
40
|
# direct dependencies of this package, installed when users `pip install utils-mystuff` later.
|
|
41
41
|
dependencies = [
|
|
42
42
|
"easygui",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"FreeSimpleGUI",
|
|
44
|
+
"hatchling",
|
|
45
|
+
"python-dateutil",
|
|
45
46
|
"pytz",
|
|
46
|
-
"pymsgbox"
|
|
47
|
+
"pymsgbox",
|
|
48
|
+
"utils-mystuff",
|
|
47
49
|
]
|
|
48
50
|
dynamic = ["version"]
|
|
49
51
|
|
|
50
52
|
[project.optional-dependencies]
|
|
51
|
-
|
|
52
|
-
"typing-extensions",
|
|
53
|
-
]
|
|
53
|
+
# n. a.
|
|
54
54
|
|
|
55
55
|
[project.scripts]
|
|
56
56
|
# n. a.
|
|
@@ -93,7 +93,7 @@ exclude = [
|
|
|
93
93
|
[tool.commitizen]
|
|
94
94
|
name = "cz_customize"
|
|
95
95
|
version_scheme = "pep440"
|
|
96
|
-
version = "1.
|
|
96
|
+
version = "1.2.0"
|
|
97
97
|
version_files = ["pyproject.toml:version"]
|
|
98
98
|
tag_format = "v$version"
|
|
99
99
|
# retry_after_failure = false
|
|
@@ -120,8 +120,8 @@ bump_map = {"feat" = "MINOR", "fix" = "PATCH", "BREAKING CHANGE" = "MAJOR"}
|
|
|
120
120
|
# with Initial Commit in changelog
|
|
121
121
|
commit_parser ="^(?P<change_type>[Ii]nitial [Cc]ommit|feat|fix|refactor|perf|docs|style|test|chore|build|ci|revert|BREAKING CHANGE)(\\((?P<scope>[^)]+)\\))?(:\\s(?P<message>.*))?"
|
|
122
122
|
changelog_pattern = "^([Ii]nitial [Cc]ommit|feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert|BREAKING CHANGE).*"
|
|
123
|
-
change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "
|
|
124
|
-
change_type_order = ["BREAKING CHANGE", "
|
|
123
|
+
change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "Code refactoring", perf = "Performance improvements", docs = "Documentation", style = "Code style", test = "Testing", chore = "Chores", build = "Build system", ci = "Continuous Integration" }
|
|
124
|
+
change_type_order = ["BREAKING CHANGE", "Features", "Bug fixes", "Code refactoring", "Performance improvements", "Documentation", "Code style", "Testing", "Chore", "Build System", "Continuous Integration", "Initial Commit"]
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
##################
|
|
@@ -140,7 +140,7 @@ ignore-args = false
|
|
|
140
140
|
ignore-kwargs = false
|
|
141
141
|
ignore-no-params = true
|
|
142
142
|
ignore_typechecker= false
|
|
143
|
-
|
|
143
|
+
disable = ["SIG305", "SIG306"]
|
|
144
144
|
# target = []
|
|
145
145
|
|
|
146
146
|
[tool.ruff]
|
|
@@ -151,8 +151,9 @@ include = [
|
|
|
151
151
|
"src/**/*.py",
|
|
152
152
|
"src/**/*.pyi",
|
|
153
153
|
"tests/**/*.py",
|
|
154
|
-
"tests/**/*.pyi"
|
|
154
|
+
"tests/**/*.pyi",
|
|
155
155
|
]
|
|
156
|
+
output-prefer-rule-codes = true
|
|
156
157
|
|
|
157
158
|
[tool.ruff.lint]
|
|
158
159
|
preview = true # preview features & checks, use with caution
|
|
@@ -247,6 +248,22 @@ warn_unused_ignores = true
|
|
|
247
248
|
warn_return_any = true
|
|
248
249
|
warn_unused_configs = true
|
|
249
250
|
|
|
251
|
+
[tool.deptry]
|
|
252
|
+
known_first_party = ["utils_mystuff"]
|
|
253
|
+
exclude = ["docs", "tests"]
|
|
254
|
+
ignore_notebooks = true
|
|
255
|
+
github_output = true
|
|
256
|
+
github_warning_errors = ["DEP003"]
|
|
257
|
+
|
|
258
|
+
[tool.deptry.package_module_name_map]
|
|
259
|
+
easygui = "easygui"
|
|
260
|
+
FreeSimpleGUI = "FreeSimpleGUI"
|
|
261
|
+
pymsgbox = "pymsgbox"
|
|
262
|
+
python-dateutil = "dateutil"
|
|
263
|
+
|
|
264
|
+
[tool.deptry.per_rule_ignores]
|
|
265
|
+
DEP002 = ["easygui", "FreeSimpleGUI", "pymsgbox"]
|
|
266
|
+
|
|
250
267
|
[tool.cruft]
|
|
251
268
|
skip = ["README.md", "CHANGELOG.MD", "src/", "tests/", "docs/", "notebooks/"]
|
|
252
269
|
|
|
@@ -256,6 +273,10 @@ addopts = "-ra -q --doctest-glob='*.md'"
|
|
|
256
273
|
testpaths = [
|
|
257
274
|
"tests",
|
|
258
275
|
]
|
|
276
|
+
markers = [
|
|
277
|
+
"integration: integration test cases",
|
|
278
|
+
"local: test cases not suitable for CI",
|
|
279
|
+
]
|
|
259
280
|
|
|
260
281
|
[tool.coverage.run]
|
|
261
282
|
branch = true
|
|
@@ -302,20 +323,21 @@ dependencies = [
|
|
|
302
323
|
]
|
|
303
324
|
# installer = "pip"
|
|
304
325
|
|
|
305
|
-
# Hatch default test environment for "hatch test" (also used in
|
|
326
|
+
# Hatch default test environment for "hatch test" (also used in GitHub Action)
|
|
327
|
+
# do not define scripts [tool.hatch.envs.hatch-test.scripts] without taking over hatch standard scripts!!!
|
|
306
328
|
[tool.hatch.envs.hatch-test]
|
|
307
329
|
dependencies = [
|
|
308
330
|
"pip",
|
|
309
331
|
"coverage-enable-subprocess==1.0",
|
|
310
|
-
"coverage[toml]
|
|
311
|
-
"pytest
|
|
312
|
-
"pytest-mock
|
|
313
|
-
"pytest-randomly
|
|
314
|
-
"pytest-rerunfailures
|
|
315
|
-
"pytest-xdist[psutil]
|
|
332
|
+
"coverage[toml]>=7.4",
|
|
333
|
+
"pytest>=8.1",
|
|
334
|
+
"pytest-mock>=3.12",
|
|
335
|
+
"pytest-randomly>=3.15",
|
|
336
|
+
"pytest-rerunfailures>=14.0",
|
|
337
|
+
"pytest-xdist[psutil]>=3.5",
|
|
316
338
|
]
|
|
317
339
|
|
|
318
|
-
#
|
|
340
|
+
# Hatch local testing environment with test-only dependencies (do not mix up with default hatch-test environment "hatch-test" !)
|
|
319
341
|
[tool.hatch.envs.test]
|
|
320
342
|
dependencies = [
|
|
321
343
|
# required test dependencies
|
|
@@ -332,28 +354,30 @@ dependencies = [
|
|
|
332
354
|
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/utils_mystuff --cov=tests {args}"
|
|
333
355
|
no-cov = "cov --no-cov {args}"
|
|
334
356
|
debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
|
|
357
|
+
test_not_local_only = "run pytest -m 'not local'"
|
|
358
|
+
test_local_only = "run pytest -m 'local'"
|
|
335
359
|
|
|
336
|
-
# Hatch testing environment matrix for various Python versions replacing the functionality of tox
|
|
360
|
+
# Hatch local testing environment matrix for various Python versions replacing the functionality of tox
|
|
337
361
|
[[tool.hatch.envs.test.matrix]]
|
|
338
362
|
template = ["test"]
|
|
339
|
-
python = ["3.
|
|
363
|
+
python = ["3.11", "3.12", "3.13", "3.14"]
|
|
340
364
|
|
|
341
365
|
# Hatch default linting environment for "hatch fmt"
|
|
342
366
|
[tool.hatch.envs.hatch-static-analysis]
|
|
343
367
|
dependencies = [
|
|
344
368
|
"pip",
|
|
345
|
-
"mypy==
|
|
346
|
-
"ruff==0.
|
|
369
|
+
"mypy==2.3.0",
|
|
370
|
+
"ruff==0.16.2",
|
|
347
371
|
]
|
|
348
372
|
|
|
349
|
-
# Hatch Linting environment for
|
|
373
|
+
# Hatch Linting environment for GitHub Action
|
|
350
374
|
[tool.hatch.envs.lint]
|
|
351
375
|
template = "lint" # don't inherit from default!
|
|
352
376
|
dependencies = [
|
|
353
377
|
"pip",
|
|
354
|
-
"mypy==
|
|
355
|
-
"ruff==0.
|
|
356
|
-
"docsig==0.
|
|
378
|
+
"mypy==2.3.0",
|
|
379
|
+
"ruff==0.16.2",
|
|
380
|
+
"docsig==0.94.0",
|
|
357
381
|
]
|
|
358
382
|
[tool.hatch.envs.lint.scripts]
|
|
359
383
|
typing = [
|
|
@@ -13,7 +13,7 @@ parsed arguments structure.
|
|
|
13
13
|
# naming conventions
|
|
14
14
|
# ruff: noqa: N801, N802, N803, N806, N812, N813, N815, N816, N818, N999
|
|
15
15
|
# others
|
|
16
|
-
# ruff: noqa: E115, E501, RUF059, SIM102
|
|
16
|
+
# ruff: noqa: E115, E501, RUF059, RUF105, SIM102
|
|
17
17
|
#
|
|
18
18
|
# disable mypy errors
|
|
19
19
|
# - mypy error "'object' has no attribute 'xyz' [attr-defined]" when accessing attributes of
|
|
@@ -48,7 +48,7 @@ True
|
|
|
48
48
|
# boolean-type arguments
|
|
49
49
|
# ruff: noqa: FBT001, FBT002
|
|
50
50
|
# others
|
|
51
|
-
# ruff: noqa: B006, E501, F841, PLW3301, RUF022
|
|
51
|
+
# ruff: noqa: B006, E501, F841, PLW3301, RUF022, RUF105
|
|
52
52
|
#
|
|
53
53
|
# disable mypy errors
|
|
54
54
|
# - errors occur when attributes of dynamically (re)loaded module(s)
|
|
@@ -12,12 +12,13 @@ Module contains filesystem related utilities.
|
|
|
12
12
|
# naming conventions
|
|
13
13
|
# ruff: noqa: N801, N802, N803, N806, N812, N813, N815, N816, N818, N999
|
|
14
14
|
# others
|
|
15
|
-
# ruff: noqa: E501, PLR1702, PLW1514, SIM102, SIM115, TID252, UP015
|
|
15
|
+
# ruff: noqa: E501, PLR1702, PLW1514, RUF105, SIM102, SIM115, TID252, UP015
|
|
16
16
|
|
|
17
17
|
# fmt: off
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
import glob
|
|
21
22
|
import os
|
|
22
23
|
import fnmatch
|
|
23
24
|
import datetime
|
|
@@ -74,7 +75,7 @@ def is_file_locked(filepath: str, waittime: float = 0.1) -> bool:
|
|
|
74
75
|
|
|
75
76
|
|
|
76
77
|
# wait for file with timeout
|
|
77
|
-
#
|
|
78
|
+
# approaches here: https://stackoverflow.com/questions/54487381/check-for-a-files-availability-for-a-certain-time-and-then-break
|
|
78
79
|
def wait_for_file(filepath: str, timeout: int = 5, waittime: float = 0.1) -> bool:
|
|
79
80
|
"""
|
|
80
81
|
wait_for_file - wait until file is available or timeout
|
|
@@ -101,6 +102,63 @@ def wait_for_file(filepath: str, timeout: int = 5, waittime: float = 0.1) -> boo
|
|
|
101
102
|
return file_exists
|
|
102
103
|
|
|
103
104
|
|
|
105
|
+
def wait_for_file_with_wildcard(filepath: str, timeout: float = 5, waittime: float = 0.1) -> str | None:
|
|
106
|
+
"""
|
|
107
|
+
wait_for_file_with_wildcard - wait until file is available or timeout
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
filepath (str): filepath with wildcard to be checked
|
|
111
|
+
timeout (int): timeout period
|
|
112
|
+
waittime (float): waittime between two checks
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
str: first found filename if found, otherwise None
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
start_time = time.time()
|
|
119
|
+
files = None
|
|
120
|
+
|
|
121
|
+
while not files:
|
|
122
|
+
time.sleep(waittime)
|
|
123
|
+
files = glob.glob(filepath)
|
|
124
|
+
if files:
|
|
125
|
+
return files[0]
|
|
126
|
+
elapsed_time = time.time() - start_time
|
|
127
|
+
if timeout > 0 and elapsed_time >= timeout:
|
|
128
|
+
break
|
|
129
|
+
|
|
130
|
+
return None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def wait_for_file_out_of_list(filepaths: list[str], timeout: float = 5, waittime: float = 0.1) -> str | None:
|
|
134
|
+
"""
|
|
135
|
+
wait_for_file_out_of_list - wait for file out of list
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
filepaths (str): list of filepaths to be checked
|
|
139
|
+
timeout (int): timeout period
|
|
140
|
+
waittime (float): waittime between two checks
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
str: first found filename if found, otherwise None
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
start_time = time.time()
|
|
147
|
+
file = None
|
|
148
|
+
|
|
149
|
+
while not file:
|
|
150
|
+
time.sleep(waittime)
|
|
151
|
+
for filepath in filepaths:
|
|
152
|
+
file = wait_for_file_with_wildcard(filepath, timeout=0.1, waittime=0.1)
|
|
153
|
+
if file:
|
|
154
|
+
return file
|
|
155
|
+
elapsed_time = time.time() - start_time
|
|
156
|
+
if timeout > 0 and elapsed_time >= timeout:
|
|
157
|
+
break
|
|
158
|
+
|
|
159
|
+
return None
|
|
160
|
+
|
|
161
|
+
|
|
104
162
|
# find latest changed file in searchpath matching filename pattern provided as searchpattern
|
|
105
163
|
# timestamp referring to nanoseconds timestamp from filesystem, otherwise problems in rare cases
|
|
106
164
|
# (1 second resolution not sufficient)
|
|
@@ -135,7 +193,7 @@ def find_last_changed_file(
|
|
|
135
193
|
while (lastchangedfile == "") and (datetime.datetime.now(dateutil.tz.tz.tzlocal()) <= timenow + datetime.timedelta(seconds=timeout_sec)):
|
|
136
194
|
|
|
137
195
|
with os.scandir(searchpath) as searchpathscan:
|
|
138
|
-
scanentry: os.DirEntry
|
|
196
|
+
scanentry: os.DirEntry # overcome PyCharm IDE error - workaround derived from https://youtrack.jetbrains.com/issue/PY-46041
|
|
139
197
|
for scanentry in searchpathscan:
|
|
140
198
|
if fnmatch.fnmatch(scanentry.name, searchpattern):
|
|
141
199
|
filemodified = scanentry.stat().st_mtime_ns / 1000000000
|
|
@@ -14,7 +14,7 @@ Module contains a collection of miscellaneous utilities.
|
|
|
14
14
|
# boolean-type arguments
|
|
15
15
|
# ruff: noqa: FBT001, FBT002, S101
|
|
16
16
|
# others
|
|
17
|
-
# ruff: noqa: B006, B905, DTZ007, E501, PLW0602, SIM102, SIM105, UP007, UP045
|
|
17
|
+
# ruff: noqa: B006, B905, DTZ007, E501, PLW0602, RUF105, SIM102, SIM105, UP007, UP045
|
|
18
18
|
#
|
|
19
19
|
# disable mypy errors
|
|
20
20
|
# mypy: disable-error-code = "unused-ignore"
|
|
@@ -25,13 +25,8 @@ Module contains a collection of miscellaneous utilities.
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
from typing import Any, TypeVar
|
|
28
|
+
from typing import Any, ParamSpec, TypeVar
|
|
29
29
|
from collections.abc import Callable
|
|
30
|
-
# importing ParamSpec in backwards compatible way
|
|
31
|
-
try:
|
|
32
|
-
from typing import ParamSpec # type: ignore
|
|
33
|
-
except ImportError:
|
|
34
|
-
from typing_extensions import ParamSpec # type: ignore
|
|
35
30
|
|
|
36
31
|
import sys
|
|
37
32
|
import os
|
|
@@ -6,7 +6,7 @@ Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
|
|
|
6
6
|
|
|
7
7
|
# ruff and mypy per file settings
|
|
8
8
|
# others
|
|
9
|
-
# ruff: noqa: PLC0415
|
|
9
|
+
# ruff: noqa: E302, PLC0415, RUF105
|
|
10
10
|
|
|
11
11
|
# fmt: off
|
|
12
12
|
|
|
@@ -14,11 +14,11 @@ Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
|
|
|
14
14
|
def _get_hatch_version():
|
|
15
15
|
"""Compute the most up-to-date version number in a development environment.
|
|
16
16
|
|
|
17
|
-
Returns `None` if Hatchling is not installed, e.g. in a production environment.
|
|
18
|
-
|
|
19
17
|
For more details, see <https://github.com/maresb/hatch-vcs-footgun-example/>.
|
|
20
18
|
"""
|
|
21
19
|
import os
|
|
20
|
+
# preparation for Pathlib
|
|
21
|
+
# from pathlib import path
|
|
22
22
|
|
|
23
23
|
try:
|
|
24
24
|
from hatchling.metadata.core import ProjectMetadata
|
|
@@ -33,9 +33,19 @@ def _get_hatch_version():
|
|
|
33
33
|
err_msg = "pyproject.toml not found although hatchling is installed"
|
|
34
34
|
raise RuntimeError(err_msg)
|
|
35
35
|
root = os.path.dirname(pyproject_toml)
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
|
|
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)
|
|
39
49
|
|
|
40
50
|
|
|
41
51
|
def _get_importlib_metadata_version():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|