rhiza 0.8.1__py3-none-any.whl → 0.8.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/cli.py CHANGED
@@ -87,22 +87,27 @@ def init(
87
87
  "--with-dev-dependencies",
88
88
  help="Include development dependencies in pyproject.toml",
89
89
  ),
90
+ git_host: str = typer.Option(
91
+ None,
92
+ "--git-host",
93
+ help="Target Git hosting platform (github or gitlab). Determines which CI/CD files to include. "
94
+ "If not provided, will prompt interactively.",
95
+ ),
90
96
  ):
91
97
  r"""Initialize or validate .github/rhiza/template.yml.
92
98
 
93
99
  Creates a default `.github/rhiza/template.yml` configuration file if one
94
100
  doesn't exist, or validates the existing configuration.
95
101
 
96
- The default template includes common Python project files:
97
- - .github (workflows, actions, etc.)
98
- - .editorconfig
99
- - .gitignore
100
- - .pre-commit-config.yaml
101
- - Makefile
102
- - pytest.ini
102
+ The default template includes common Python project files.
103
+ The --git-host option determines which CI/CD configuration to include:
104
+ - github: includes .github folder (GitHub Actions workflows)
105
+ - gitlab: includes .gitlab-ci.yml (GitLab CI configuration)
103
106
 
104
107
  Examples:
105
108
  rhiza init
109
+ rhiza init --git-host github
110
+ rhiza init --git-host gitlab
106
111
  rhiza init /path/to/project
107
112
  rhiza init ..
108
113
  """
@@ -111,6 +116,7 @@ def init(
111
116
  project_name=project_name,
112
117
  package_name=package_name,
113
118
  with_dev_dependencies=with_dev_dependencies,
119
+ git_host=git_host,
114
120
  )
115
121
 
116
122
 
rhiza/commands/init.py CHANGED
@@ -8,8 +8,10 @@ and what paths are governed by Rhiza.
8
8
  import importlib.resources
9
9
  import keyword
10
10
  import re
11
+ import sys
11
12
  from pathlib import Path
12
13
 
14
+ import typer
13
15
  from jinja2 import Template
14
16
  from loguru import logger
15
17
 
@@ -45,6 +47,7 @@ def init(
45
47
  project_name: str | None = None,
46
48
  package_name: str | None = None,
47
49
  with_dev_dependencies: bool = False,
50
+ git_host: str | None = None,
48
51
  ):
49
52
  """Initialize or validate .github/rhiza/template.yml in the target repository.
50
53
 
@@ -56,6 +59,8 @@ def init(
56
59
  project_name: Custom project name. Defaults to target directory name.
57
60
  package_name: Custom package name. Defaults to normalized project name.
58
61
  with_dev_dependencies: Include development dependencies in pyproject.toml.
62
+ git_host: Target Git hosting platform ("github" or "gitlab"). Determines which
63
+ CI/CD configuration files to include. If None, will prompt user interactively.
59
64
 
60
65
  Returns:
61
66
  bool: True if validation passes, False otherwise.
@@ -63,6 +68,13 @@ def init(
63
68
  # Convert to absolute path to avoid surprises
64
69
  target = target.resolve()
65
70
 
71
+ # Validate git_host if provided
72
+ if git_host is not None:
73
+ git_host = git_host.lower()
74
+ if git_host not in ["github", "gitlab"]:
75
+ logger.error(f"Invalid git-host: {git_host}. Must be 'github' or 'gitlab'")
76
+ raise ValueError(f"Invalid git-host: {git_host}. Must be 'github' or 'gitlab'")
77
+
66
78
  logger.info(f"Initializing Rhiza configuration in: {target}")
67
79
 
68
80
  # Create .rhiza directory structure if it doesn't exist
@@ -79,12 +91,51 @@ def init(
79
91
  logger.info("Creating default .rhiza/template.yml")
80
92
  logger.debug("Using default template configuration")
81
93
 
82
- # Default template points to the jebel-quant/rhiza repository
83
- # and includes common Python project configuration files
84
- default_template = RhizaTemplate(
85
- template_repository="jebel-quant/rhiza",
86
- template_branch="main",
87
- include=[
94
+ # Prompt for target git hosting platform if not provided
95
+ if git_host is None:
96
+ # Only prompt if running in an interactive terminal
97
+ if sys.stdin.isatty():
98
+ logger.info("Where will your project be hosted?")
99
+ git_host = typer.prompt(
100
+ "Target Git hosting platform (github/gitlab)",
101
+ type=str,
102
+ default="github",
103
+ ).lower()
104
+
105
+ # Validate the input
106
+ while git_host not in ["github", "gitlab"]:
107
+ logger.warning(f"Invalid choice: {git_host}. Please choose 'github' or 'gitlab'")
108
+ git_host = typer.prompt(
109
+ "Target Git hosting platform (github/gitlab)",
110
+ type=str,
111
+ default="github",
112
+ ).lower()
113
+ else:
114
+ # Non-interactive mode (e.g., tests), default to github
115
+ git_host = "github"
116
+ logger.debug("Non-interactive mode detected, defaulting to github")
117
+
118
+ # Adjust template based on target git hosting platform
119
+ # The template repository is always on GitHub (jebel-quant/rhiza)
120
+ # but we include different files based on where the target project will be
121
+ if git_host == "gitlab":
122
+ include_paths = [
123
+ ".rhiza", # .rhiza folder
124
+ ".gitlab", # .gitlab folder
125
+ ".gitlab-ci.yml", # GitLab CI configuration
126
+ ".editorconfig", # Editor configuration
127
+ ".gitignore", # Git ignore patterns
128
+ ".pre-commit-config.yaml", # Pre-commit hooks
129
+ "ruff.toml", # Ruff linter configuration
130
+ "Makefile", # Build and development tasks
131
+ "pytest.ini", # Pytest configuration
132
+ "book", # Documentation book
133
+ "presentation", # Presentation materials
134
+ "tests", # Test structure
135
+ ]
136
+ else:
137
+ include_paths = [
138
+ ".rhiza", # .rhiza folder
88
139
  ".github", # GitHub configuration and workflows
89
140
  ".editorconfig", # Editor configuration
90
141
  ".gitignore", # Git ignore patterns
@@ -95,7 +146,16 @@ def init(
95
146
  "book", # Documentation book
96
147
  "presentation", # Presentation materials
97
148
  "tests", # Test structure
98
- ],
149
+ ]
150
+
151
+ # Default template points to the jebel-quant/rhiza repository on GitHub
152
+ # and includes files appropriate for the target platform
153
+ default_template = RhizaTemplate(
154
+ template_repository="jebel-quant/rhiza",
155
+ template_branch="main",
156
+ # template_host is not set here - it defaults to "github" in the model
157
+ # because the template repository is on GitHub
158
+ include=include_paths,
99
159
  )
100
160
 
101
161
  # Write the default template to the file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rhiza
3
- Version: 0.8.1
3
+ Version: 0.8.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
@@ -1,19 +1,19 @@
1
1
  rhiza/__init__.py,sha256=iW3niLBjwRKxcMhIV_1eb78putjUTo2tbZsadofluJk,1939
2
2
  rhiza/__main__.py,sha256=Lx0GqVZo6ymm0f18_uYB6E7_SOWwJNYjb73Vr31oLoM,236
3
- rhiza/cli.py,sha256=I5A5d1-3xrL2gdh5H9Itm9uiQjoPiGEbHYyxXddHEOk,8196
3
+ rhiza/cli.py,sha256=xIsyfKjSFjVLjCS7o2om5o_YLZx9lIhsI0MTMI5Zs2k,8594
4
4
  rhiza/models.py,sha256=fW9lofkkid-bghk2bXEgBdGbZ4scSqG726fMrVfKX_M,3454
5
5
  rhiza/_templates/basic/__init__.py.jinja2,sha256=gs8qN4LAKcdFd6iO9gZVLuVetODmZP_TGuEjWrbinC0,27
6
6
  rhiza/_templates/basic/main.py.jinja2,sha256=uTCahxf9Bftao1IghHue4cSZ9YzBYmBEXeIhEmK9UXQ,362
7
7
  rhiza/_templates/basic/pyproject.toml.jinja2,sha256=Mizpnnd_kFQd-pCWOxG-KWhvg4_ZhZaQppTt2pz0WOc,695
8
8
  rhiza/commands/__init__.py,sha256=Z5CeMh7ylX27H6dvwqRbEKzYo5pwQq-5TyTxABUSaQg,1848
9
- rhiza/commands/init.py,sha256=RsYmomOq-00b4bAjseiHR7ljgJQ_XSjDX-ZWKYTPPN8,6787
9
+ rhiza/commands/init.py,sha256=sSNLtERaBXLrZ1g6fe78yk5VVTXcAO4YiyAQdVD5I4A,9636
10
10
  rhiza/commands/materialize.py,sha256=AbVXJrR8faa3t7m_Xl5TR8VE3ODmkh2oiAwCYFA36wA,17343
11
11
  rhiza/commands/migrate.py,sha256=hhSkj2iafCCxKrrVOfnPWDjK7fTJ5ReAJsWNDGz71s0,6307
12
12
  rhiza/commands/uninstall.py,sha256=z95xqamV7wGPr8PBveWzaRmtD5bPhOrTLI0GcOvpnAo,5371
13
13
  rhiza/commands/validate.py,sha256=1HMQWF9Syv7JKC31AkaPYMTnqy8HOvAMxMLrYty36FQ,9112
14
14
  rhiza/commands/welcome.py,sha256=w3BziR042o6oYincd3EqDsFzF6qqInU7iYhWjF3yJqY,2382
15
- rhiza-0.8.1.dist-info/METADATA,sha256=hLiWkbsUmak3dR65CSnQokItVSl9X9aYBXFPef0s088,25156
16
- rhiza-0.8.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
- rhiza-0.8.1.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
18
- rhiza-0.8.1.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
19
- rhiza-0.8.1.dist-info/RECORD,,
15
+ rhiza-0.8.3.dist-info/METADATA,sha256=KCV-nTc54f3k5cix84ldW355IF_LX2tdwxImgZebg9c,25156
16
+ rhiza-0.8.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
+ rhiza-0.8.3.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
18
+ rhiza-0.8.3.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
19
+ rhiza-0.8.3.dist-info/RECORD,,
File without changes