iker-python-setup 1.0.999999__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.
iker/setup/__init__.py ADDED
@@ -0,0 +1,92 @@
1
+ import importlib.metadata
2
+ import os
3
+
4
+ try:
5
+ __version__ = importlib.metadata.version("iker-python-setup")
6
+ except importlib.metadata.PackageNotFoundError:
7
+ __version__ = "unknown"
8
+
9
+ __all__ = [
10
+ "version_string_local",
11
+ "version_string_scm",
12
+ "version_string",
13
+ "setup",
14
+ ]
15
+
16
+
17
+ def read_version_tuple(cwd: str | None = None,
18
+ *,
19
+ default: (int, int, int) = (0, 1, 0),
20
+ version_file: str = "VERSION",
21
+ patch_env_var: str = "BUILD_NUMBER",
22
+ strict: bool = False) -> (int, int, int):
23
+ if cwd is None:
24
+ cwd = os.getcwd()
25
+ try:
26
+ with open(os.path.join(cwd, version_file)) as fh:
27
+ major_str, minor_str, *patch_strs = fh.read().strip().split(".")
28
+
29
+ major = max(0, int(major_str))
30
+ minor = max(0, int(minor_str))
31
+
32
+ patch_str = patch_strs[0] if len(patch_strs) > 0 else os.getenv(patch_env_var)
33
+ patch = 999999 if patch_str is None else min(999999, max(0, int(patch_str)))
34
+
35
+ return major, minor, patch
36
+ except Exception as e:
37
+ if strict:
38
+ raise e
39
+ return default
40
+
41
+
42
+ def version_string_local(cwd: str | None = None) -> str:
43
+ major, minor, patch = read_version_tuple(cwd, strict=True)
44
+ return f"{major}.{minor}.{patch}"
45
+
46
+
47
+ def version_string_scm(cwd: str | None = None) -> str:
48
+ from setuptools_scm import ScmVersion
49
+ from setuptools_scm import get_version
50
+ if cwd is None:
51
+ cwd = os.getcwd()
52
+
53
+ def find_scm_root(cd: str) -> str:
54
+ cd = os.path.abspath(cd)
55
+ for item in os.listdir(cd):
56
+ if os.path.isdir(os.path.join(cd, item)) and item == ".git":
57
+ return cd
58
+ pd = os.path.dirname(cd)
59
+ if pd == cd:
60
+ raise ValueError("Cannot find SCM root properly")
61
+ return find_scm_root(pd)
62
+
63
+ def version_scheme_callback(scm_version: ScmVersion) -> str:
64
+ major, minor, patch = read_version_tuple(cwd, strict=True)
65
+ if scm_version.branch == "master" or os.getenv("GIT_BRANCH", "") == "master":
66
+ return f"{major}.{minor}.{patch}"
67
+ return f"{major}.{minor}.{0}"
68
+
69
+ def local_scheme_callback(scm_version: ScmVersion) -> str:
70
+ if scm_version.branch == "master" or os.getenv("GIT_BRANCH", "") == "master":
71
+ return ""
72
+ node_datetime = scm_version.time.strftime("%Y%m%d%H%M%S")
73
+ if scm_version.dirty:
74
+ return scm_version.format_with("+{node_datetime}.post{distance}.{node}.dirty", node_datetime=node_datetime)
75
+ return scm_version.format_with("+{node_datetime}.post{distance}.{node}", node_datetime=node_datetime)
76
+
77
+ return get_version(root=find_scm_root(cwd),
78
+ version_scheme=version_scheme_callback,
79
+ local_scheme=local_scheme_callback,
80
+ normalize=True)
81
+
82
+
83
+ def version_string(cwd: str | None = None):
84
+ try:
85
+ return version_string_scm(cwd)
86
+ except Exception:
87
+ return version_string_local(cwd)
88
+
89
+
90
+ def setup():
91
+ from setuptools import setup
92
+ setup(version=version_string())
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.1
2
+ Name: iker-python-setup
3
+ Version: 1.0.999999
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Python :: 3.11
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Requires-Python: <3.13,>=3.11
8
+ Requires-Dist: setuptools ~=72.0
9
+ Requires-Dist: setuptools-scm ~=8.0
10
+ Provides-Extra: test
11
+ Requires-Dist: pytest-cov ~=5.0 ; extra == 'test'
12
+ Requires-Dist: pytest-order ~=1.2 ; extra == 'test'
13
+ Requires-Dist: pytest ~=8.3 ; extra == 'test'
14
+
@@ -0,0 +1,5 @@
1
+ iker/setup/__init__.py,sha256=7Y2cTFfXnjrwFPVlIzYyDUut1_Dn2anW0X28azabbvA,3123
2
+ iker_python_setup-1.0.999999.dist-info/METADATA,sha256=mH-pQdz1__O9uAFAEjnoATTEuwNo8eBGhsISdioh8zM,485
3
+ iker_python_setup-1.0.999999.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
4
+ iker_python_setup-1.0.999999.dist-info/top_level.txt,sha256=4_B8Prfc_lxFafFYTQThIU1ZqOYQ4pHHHnJ_fQ_oHs8,5
5
+ iker_python_setup-1.0.999999.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (72.2.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+