From 786b592de142acf7446cdcee7ee79cb6b0efe814 Mon Sep 17 00:00:00 2001 From: BJ Dierkes Date: Sat, 9 Nov 2024 22:32:38 -0600 Subject: [PATCH] Add FrameworkError Message if Yaml/Jinja2 are Missing --- CHANGELOG.md | 22 ++++++++++++++++++---- cement/cli/main.py | 7 +++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cbd1c58..73ce04dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,12 @@ Bugs: -- ? +- None Features: -- ? +- None Refactoring: @@ -73,12 +73,13 @@ Refactoring: Misc: -- ? +- [cli] Move CLI dependencies to `cement[cli]` extras package, and remove included/nexted `contrib` sources. See note on 'Potential Upgrade Incompatibility' + - [Issue #679](https://github.com/datafolklabs/cement/issues/679) Deprecations: -- ? +- None Special Recognitions: @@ -88,6 +89,19 @@ Many thanks to [@sigma67](https://github.com/sigma67) for their contributions in Many thanks to [@rednar](https://github.com/rednar) for their contributions toward adding type annotations in [PR #628](https://github.com/datafolklabs/cement/pull/628). This PR was too large to merge directly, but it is serving as a guide to finally begin work toward adding type annotations to Cement. This was a massive effort, and is very helpful to have this work available to guide the effort even if it will not be merged directly. +Potential Upgrade Incompatibility: + +This update removes included `contrib` libraries that are dependencies for the `cement` command line tool to function (PyYAML, and Jinja2). The dependencies are now included via the `cement[cli]` extras package. + +This is not an upgrade incompatibility in the core Cement code, and it would not affect any applications that are built on Cement. That said, it does have the potential to break any automation or other uses of the `cement` command line tool. + +Resolution: + +``` +pip install cement[cli] +``` + + ## 3.0.10 - Feb 28, 2024 Bugs: diff --git a/cement/cli/main.py b/cement/cli/main.py index 46ef357d..0079a980 100644 --- a/cement/cli/main.py +++ b/cement/cli/main.py @@ -3,6 +3,7 @@ from typing import Optional, List from cement import App, CaughtSignal # noqa: E402 from .controllers.base import Base # noqa: E402 +from cement.core.exc import FrameworkError class CementApp(App): @@ -33,6 +34,12 @@ class Meta: def main(argv: Optional[List[str]] = None) -> None: + # Issue #679: https://github.com/datafolklabs/cement/issues/679 + try: + import yaml, jinja2 + except ModuleNotFoundError as e: + raise FrameworkError('Cement CLI Dependencies are missing! Install cement[cli] extras package to resolve -> pip install cement[cli]') + with CementApp() as app: try: app.run()