Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromfrappe/bench

Commitab9b617

Browse files
authored
feat:bench validate-dependencies command (frappe#1534)
This validates all `frappe-dependencies` and exits with 1 if any ofspecifications fail.This will be internal feature for FC for now. If this works well we canmake the validation fail during install-app itself without requiring anyadditional command/steps.
1 parent1a42175 commitab9b617

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

‎bench/app.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def get_pyproject(self) -> Optional[dict]:
308308
self.pyproject=get_pyproject(pyproject_path)
309309
returnself.pyproject
310310

311-
defvalidate_app_dependencies(self)->None:
311+
defvalidate_app_dependencies(self,throw=False)->None:
312312
pyproject=self.get_pyproject()or {}
313313
deps:Optional[dict]= (
314314
pyproject.get("tool", {}).get("bench", {}).get("frappe-dependencies")
@@ -317,7 +317,7 @@ def validate_app_dependencies(self) -> None:
317317
return
318318

319319
fordep,versionindeps.items():
320-
validate_dependency(self,dep,version)
320+
validate_dependency(self,dep,version,throw=throw)
321321

322322
"""
323323
Get App Cache
@@ -489,16 +489,13 @@ def can_frappe_use_cached(app: App) -> bool:
489489
returnFalse
490490

491491

492-
defvalidate_dependency(app:App,dep:str,req_version:str)->None:
492+
defvalidate_dependency(app:App,dep:str,req_version:str,throw=False)->None:
493493
dep_path=Path(app.bench.name)/"apps"/dep
494494
ifnotdep_path.is_dir():
495-
click.secho(
496-
f"Required frappe-dependency '{dep}' not found. "
497-
f"Aborting '{app.name}' installation. "
498-
f"Please install '{dep}' first and retry",
499-
fg="red",
500-
)
501-
sys.exit(1)
495+
click.secho(f"Required frappe-dependency '{dep}' not found.",fg="yellow")
496+
ifthrow:
497+
sys.exit(1)
498+
return
502499

503500
dep_version=get_dep_version(dep,dep_path)
504501
ifnotdep_version:
@@ -508,9 +505,12 @@ def validate_dependency(app: App, dep: str, req_version: str) -> None:
508505
click.secho(
509506
f"Installed frappe-dependency '{dep}' version '{dep_version}' "
510507
f"does not satisfy required version '{req_version}'. "
511-
f"App '{app.name}' might not work as expected",
508+
f"App '{app.name}' might not work as expected.",
512509
fg="yellow",
513510
)
511+
ifthrow:
512+
click.secho(f"Please install '{dep}{req_version}' first and retry",fg="red")
513+
sys.exit(1)
514514

515515

516516
defget_dep_version(dep:str,dep_path:Path)->Optional[str]:

‎bench/commands/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def bench_command(bench_path="."):
4646
new_app,
4747
pip,
4848
remove_app,
49+
validate_dependencies,
4950
)
5051

5152
bench_command.add_command(init)
@@ -56,6 +57,7 @@ def bench_command(bench_path="."):
5657
bench_command.add_command(exclude_app_for_update)
5758
bench_command.add_command(include_app_for_update)
5859
bench_command.add_command(pip)
60+
bench_command.add_command(validate_dependencies)
5961

6062

6163
frombench.commands.updateimport (

‎bench/commands/make.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,20 @@ def pip(ctx, args):
253253

254254
env_py=get_env_cmd("python")
255255
os.execv(env_py, (env_py,"-m","pip")+args)
256+
257+
258+
@click.command(
259+
"validate-dependencies",
260+
help="Validates that all requirements specified in frappe-dependencies are met curently.",
261+
)
262+
@click.pass_context
263+
defvalidate_dependencies(ctx):
264+
"Validate all specified frappe-dependencies."
265+
frombench.benchimportBench
266+
frombench.appimportApp
267+
268+
bench=Bench(".")
269+
270+
forapp_nameinbench.apps:
271+
app=App(app_name,bench=bench)
272+
app.validate_app_dependencies(throw=True)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp