rhiza 0.5.2__py3-none-any.whl → 0.5.3__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.
rhiza/__init__.py CHANGED
@@ -4,4 +4,12 @@ This package groups small, user-facing utilities that can be invoked from
4
4
  the command line or other automation scripts.
5
5
  """
6
6
 
7
+ from importlib.metadata import PackageNotFoundError, version
8
+
9
+ try:
10
+ __version__ = version("rhiza")
11
+ except PackageNotFoundError:
12
+ # Package is not installed, use a fallback version
13
+ __version__ = "0.0.0+dev"
14
+
7
15
  __all__ = ["commands", "models"]
rhiza/cli.py CHANGED
@@ -8,6 +8,7 @@ from pathlib import Path
8
8
 
9
9
  import typer
10
10
 
11
+ from rhiza import __version__
11
12
  from rhiza.commands import init as init_cmd
12
13
  from rhiza.commands import materialize as materialize_cmd
13
14
  from rhiza.commands import validate as validate_cmd
@@ -18,6 +19,41 @@ app = typer.Typer(
18
19
  )
19
20
 
20
21
 
22
+ def version_callback(value: bool):
23
+ """Print version information and exit.
24
+
25
+ Args:
26
+ value: Whether the --version flag was provided.
27
+
28
+ Raises:
29
+ typer.Exit: Always exits after printing version.
30
+ """
31
+ if value:
32
+ typer.echo(f"rhiza version {__version__}")
33
+ raise typer.Exit()
34
+
35
+
36
+ @app.callback()
37
+ def main(
38
+ version: bool = typer.Option(
39
+ False,
40
+ "--version",
41
+ "-v",
42
+ help="Show version and exit",
43
+ callback=version_callback,
44
+ is_eager=True,
45
+ ),
46
+ ):
47
+ """Rhiza CLI main callback.
48
+
49
+ This callback is executed before any command. It handles global options
50
+ like --version.
51
+
52
+ Args:
53
+ version: Version flag (handled by callback).
54
+ """
55
+
56
+
21
57
  @app.command()
22
58
  def init(
23
59
  target: Path = typer.Argument(
rhiza/commands/init.py CHANGED
@@ -61,4 +61,4 @@ Next steps:
61
61
  """)
62
62
 
63
63
  # the template file exists, so validate it
64
- validate(target)
64
+ return validate(target)
@@ -1,5 +1,14 @@
1
+ """Command for materializing Rhiza template files into a repository.
2
+
3
+ This module implements the `materialize` command. It performs a sparse
4
+ checkout of the configured template repository, copies the selected files
5
+ into the target Git repository, and records managed files in
6
+ `.rhiza.history`. Use this to take a one-shot snapshot of template files.
7
+ """
8
+
1
9
  import shutil
2
10
  import subprocess
11
+ import sys
3
12
  import tempfile
4
13
  from pathlib import Path
5
14
 
@@ -43,7 +52,11 @@ def materialize(target: Path, branch: str, force: bool) -> None:
43
52
  # -----------------------
44
53
  # Ensure Rhiza is initialized
45
54
  # -----------------------
46
- init(target)
55
+ valid = init(target)
56
+
57
+ if not valid:
58
+ logger.error(f"Rhiza template is invalid. {target}")
59
+ sys.exit(1)
47
60
 
48
61
  template_file = target / ".github" / "template.yml"
49
62
  template = RhizaTemplate.from_yaml(template_file)
@@ -73,10 +86,12 @@ def materialize(target: Path, branch: str, force: bool) -> None:
73
86
  [
74
87
  "git",
75
88
  "clone",
76
- "--depth", "1",
89
+ "--depth",
90
+ "1",
77
91
  "--filter=blob:none",
78
92
  "--sparse",
79
- "--branch", rhiza_branch,
93
+ "--branch",
94
+ rhiza_branch,
80
95
  f"https://github.com/{rhiza_repo}.git",
81
96
  str(tmp_dir),
82
97
  ],
@@ -101,15 +116,9 @@ def materialize(target: Path, branch: str, force: bool) -> None:
101
116
  # -----------------------
102
117
  all_files = expand_paths(tmp_dir, include_paths)
103
118
 
104
- excluded_files = {
105
- f.resolve()
106
- for f in expand_paths(tmp_dir, excluded_paths)
107
- }
119
+ excluded_files = {f.resolve() for f in expand_paths(tmp_dir, excluded_paths)}
108
120
 
109
- files_to_copy = [
110
- f for f in all_files
111
- if f.resolve() not in excluded_files
112
- ]
121
+ files_to_copy = [f for f in all_files if f.resolve() not in excluded_files]
113
122
 
114
123
  # -----------------------
115
124
  # Copy files into target repo
@@ -121,9 +130,7 @@ def materialize(target: Path, branch: str, force: bool) -> None:
121
130
  materialized_files.append(relative_path)
122
131
 
123
132
  if dst_file.exists() and not force:
124
- logger.warning(
125
- f"{relative_path} already exists — use --force to overwrite"
126
- )
133
+ logger.warning(f"{relative_path} already exists — use --force to overwrite")
127
134
  continue
128
135
 
129
136
  dst_file.parent.mkdir(parents=True, exist_ok=True)
@@ -136,10 +143,7 @@ def materialize(target: Path, branch: str, force: bool) -> None:
136
143
  # -----------------------
137
144
  # Warn about workflow files
138
145
  # -----------------------
139
- workflow_files = [
140
- p for p in materialized_files
141
- if p.parts[:2] == (".github", "workflows")
142
- ]
146
+ workflow_files = [p for p in materialized_files if p.parts[:2] == (".github", "workflows")]
143
147
 
144
148
  if workflow_files:
145
149
  logger.warning(
@@ -161,10 +165,7 @@ def materialize(target: Path, branch: str, force: bool) -> None:
161
165
  for file_path in sorted(materialized_files):
162
166
  f.write(f"{file_path}\n")
163
167
 
164
- logger.info(
165
- f"Created {history_file.relative_to(target)} "
166
- f"with {len(materialized_files)} files"
167
- )
168
+ logger.info(f"Created {history_file.relative_to(target)} with {len(materialized_files)} files")
168
169
 
169
170
  logger.success("Rhiza templates materialized successfully")
170
171
 
@@ -133,4 +133,5 @@ def validate(target: Path) -> bool:
133
133
  return True
134
134
  else:
135
135
  logger.error("✗ Validation failed: template.yml has errors")
136
+ # raise AssertionError("Invalid template.yml")
136
137
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rhiza
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Reusable configuration templates for modern Python projects
5
5
  Project-URL: Homepage, https://github.com/jebel-quant/rhiza-cli
6
6
  Project-URL: Repository, https://github.com/jebel-quant/rhiza-cli
@@ -0,0 +1,13 @@
1
+ rhiza/__init__.py,sha256=KHBklJoM7XnW9oXCZqO2Cn-EHvo2z8m3IzzJA06W4qY,441
2
+ rhiza/__main__.py,sha256=Lx0GqVZo6ymm0f18_uYB6E7_SOWwJNYjb73Vr31oLoM,236
3
+ rhiza/cli.py,sha256=20pzeIocwaPRQPtvjb4cguiXg8RGhfRkrn3FtNq9I0Q,4224
4
+ rhiza/models.py,sha256=-n5eyPcU35IVsbvy7F-kyKR343TkOrx25kooLCF9whg,3001
5
+ rhiza/commands/__init__.py,sha256=KcoFX52xQ1NFdgVeGsAkIaqmJrRso1GOq0vFL0WEB44,300
6
+ rhiza/commands/init.py,sha256=QsOV_VBnRfSPebydH-fMe3haadboNIAYlOpAIYHtgUs,1936
7
+ rhiza/commands/materialize.py,sha256=7_LqDBrdRHmsmG50LIJ7aHBeXEj4TW8TwSsmUUYg8aE,5877
8
+ rhiza/commands/validate.py,sha256=7K69mP1Z42JLYKf2H1egQcR5qhFKlTAE61vYvowvoI4,4884
9
+ rhiza-0.5.3.dist-info/METADATA,sha256=MCD0DNFBrNPRmt5SMtk5cDGNuCczWhrHeVi4yT_scbo,19938
10
+ rhiza-0.5.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
11
+ rhiza-0.5.3.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
12
+ rhiza-0.5.3.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
13
+ rhiza-0.5.3.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- rhiza/__init__.py,sha256=1AECbLiERqRhdcFkVxHk3vEK4KPWll-D05CTAHZDI2A,224
2
- rhiza/__main__.py,sha256=Lx0GqVZo6ymm0f18_uYB6E7_SOWwJNYjb73Vr31oLoM,236
3
- rhiza/cli.py,sha256=v7VaGUEnfuGRMOGh8I7Luh-QiUHj0to7tsSXVFuUyts,3458
4
- rhiza/models.py,sha256=-n5eyPcU35IVsbvy7F-kyKR343TkOrx25kooLCF9whg,3001
5
- rhiza/commands/__init__.py,sha256=KcoFX52xQ1NFdgVeGsAkIaqmJrRso1GOq0vFL0WEB44,300
6
- rhiza/commands/init.py,sha256=K8NN9x_gMWeoD1gx9PCDkGUCN3luxZgp7tVD2jCqT94,1929
7
- rhiza/commands/materialize.py,sha256=6dE5uG41HkSERFqupS29PaHh32lveHRvbxEttaCfBpk,5525
8
- rhiza/commands/validate.py,sha256=itcLg44GiuZ7hZ67Bscj1RavdERlWgq40rJDaYOp2zM,4829
9
- rhiza-0.5.2.dist-info/METADATA,sha256=3X4vrQOv-eb1Znj_VAq8J5OmHAPI3V6vgM4dNTSasaw,19938
10
- rhiza-0.5.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
11
- rhiza-0.5.2.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
12
- rhiza-0.5.2.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
13
- rhiza-0.5.2.dist-info/RECORD,,
File without changes