From 3f31496af3015c047845f84fa9c233dff9bb5b8c Mon Sep 17 00:00:00 2001 From: Sina Atalay <79940989+sinaatalay@users.noreply.github.com> Date: Sat, 25 Jan 2025 17:11:54 -0500 Subject: [PATCH] Fix partial installation errors (#326) * make dependencies more flexible * Fix partial installation errors --- pyproject.toml | 18 ++++++++++-------- rendercv/cli/__init__.py | 33 +++++++++++++++++++-------------- rendercv/cli/commands.py | 8 +------- rendercv/cli/printer.py | 18 +++--------------- rendercv/cli/utilities.py | 18 +++--------------- rendercv/data/generator.py | 8 +------- rendercv/data/reader.py | 7 +------ 7 files changed, 38 insertions(+), 72 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e2ac6864..d66790cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,12 +56,13 @@ requires-python = '>=3.10' # RenderCV depends on these packages. They will be installed automatically when RenderCV # is installed: dependencies = [ - 'Jinja2==3.1.5', # to generate Typst and Markdown files + 'Jinja2>=3.1.3', # to generate Typst and Markdown files 'phonenumbers==8.13.53', # to validate phone numbers 'email-validator==2.2.0', # to validate email addresses 'pydantic==2.10.5', # to validate and parse the input file 'pycountry==24.6.1', # for ISO 639-3 validation 'pydantic-extra-types==2.10.2', # to validate some extra types + 'ruamel.yaml==0.18.6', # to parse YAML files ] classifiers = [ "Intended Audience :: Science/Research", @@ -72,6 +73,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] # go to https://pypi.org/classifiers/ to see all classifiers @@ -79,18 +81,18 @@ dynamic = ["version"] # We will use hatchling to generate the version number [project.optional-dependencies] full = [ - 'ruamel.yaml==0.18.6', # to parse YAML files - 'typer==0.15.1', # to create the command-line interface - "markdown==3.7", # to convert Markdown to HTML - "watchdog==6.0.0", # to poll files for updates - "typst==0.12.2", # to render PDF from Typst source files - "rendercv-fonts==0.3.0", # some font files for RenderCV - "packaging==24.2", # to validate the version number + 'typer==0.15.1', # to create the command-line interface + "markdown==3.7", # to convert Markdown to HTML + "watchdog==6.0.0", # to poll files for updates + "typst==0.12.3", # to render PDF from Typst source files + "rendercv-fonts", # some font files for RenderCV + "packaging==24.2", # to validate the version number ] [project.urls] # Here, we can specify the URLs related to RenderCV. They will be listed under the # "Project links" section in PyPI. See https://pypi.org/project/rendercv/ +"Web App" = 'https://rendercv.com' Source = 'https://github.com/rendercv/rendercv' Documentation = 'https://docs.rendercv.com' Changelog = 'https://docs.rendercv.com/changelog' diff --git a/rendercv/cli/__init__.py b/rendercv/cli/__init__.py index 735ad50f..7229f6c2 100644 --- a/rendercv/cli/__init__.py +++ b/rendercv/cli/__init__.py @@ -5,18 +5,23 @@ CLI and [Rich](https://rich.readthedocs.io/en/latest/) to provide a nice-looking interface. """ -from .commands import ( - app, - cli_command_create_theme, - cli_command_new, - cli_command_no_args, - cli_command_render, -) +try: + from .commands import ( + app, + cli_command_create_theme, + cli_command_new, + cli_command_no_args, + cli_command_render, + ) -__all__ = [ - "app", - "cli_command_create_theme", - "cli_command_new", - "cli_command_no_args", - "cli_command_render", -] + __all__ = [ + "app", + "cli_command_create_theme", + "cli_command_new", + "cli_command_no_args", + "cli_command_render", + ] +except ImportError as e: + from .. import _parial_install_error_message + + raise ImportError(_parial_install_error_message) from e diff --git a/rendercv/cli/commands.py b/rendercv/cli/commands.py index 0a4a979e..c68ede97 100644 --- a/rendercv/cli/commands.py +++ b/rendercv/cli/commands.py @@ -7,18 +7,12 @@ import copy import pathlib from typing import Annotated, Optional +import typer from rich import print from .. import __version__, data from . import printer, utilities -try: - import typer -except ImportError as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e - app = typer.Typer( rich_markup_mode="rich", add_completion=False, diff --git a/rendercv/cli/printer.py b/rendercv/cli/printer.py index 0a29fba7..cea1b687 100644 --- a/rendercv/cli/printer.py +++ b/rendercv/cli/printer.py @@ -8,6 +8,7 @@ from collections.abc import Callable from typing import Optional import jinja2 +import packaging.version import pydantic import rich import rich.live @@ -15,15 +16,8 @@ import rich.panel import rich.progress import rich.table import rich.text - -try: - import typer -except ImportError as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e - -import packaging.version +import ruamel.yaml +import typer from rich import print from .. import __version__, data @@ -267,12 +261,6 @@ def handle_and_print_raised_exceptions_without_exit(function: Callable) -> Calla Returns: The wrapped function. """ - try: - import ruamel.yaml - except Exception as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e @functools.wraps(function) def wrapper(*args, **kwargs): diff --git a/rendercv/cli/utilities.py b/rendercv/cli/utilities.py index e1d8f309..6ab19d17 100644 --- a/rendercv/cli/utilities.py +++ b/rendercv/cli/utilities.py @@ -13,14 +13,10 @@ import urllib.request from collections.abc import Callable from typing import Any, Optional -try: - import typer -except ImportError as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e - import packaging.version +import typer +import watchdog.events +import watchdog.observers from .. import data, renderer from . import printer @@ -424,14 +420,6 @@ def run_a_function_if_a_file_changes(file_path: pathlib.Path, function: Callable file_path (pathlib.Path): The path of the file to watch for. function (Callable): The function to be called on file modification. """ - try: - import watchdog.events - import watchdog.observers - except Exception as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e - # Run the function immediately for the first time function() diff --git a/rendercv/data/generator.py b/rendercv/data/generator.py index 505854a4..6ae8961f 100644 --- a/rendercv/data/generator.py +++ b/rendercv/data/generator.py @@ -9,6 +9,7 @@ import pathlib from typing import Optional import pydantic +import ruamel.yaml from . import models, reader @@ -22,13 +23,6 @@ def dictionary_to_yaml(dictionary: dict) -> str: Returns: The YAML string. """ - try: - import ruamel.yaml - except Exception as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e - yaml_object = ruamel.yaml.YAML() yaml_object.encoding = "utf-8" yaml_object.width = 60 diff --git a/rendercv/data/reader.py b/rendercv/data/reader.py index 7f08ce57..57fea7df 100644 --- a/rendercv/data/reader.py +++ b/rendercv/data/reader.py @@ -9,6 +9,7 @@ import re from typing import Optional import pydantic +import ruamel.yaml from . import models from .models import entry_types @@ -225,12 +226,6 @@ def read_a_yaml_file(file_path_or_contents: pathlib.Path | str) -> dict: Returns: The content of the YAML file as a dictionary. """ - try: - import ruamel.yaml - except Exception as e: - from .. import _parial_install_error_message - - raise ImportError(_parial_install_error_message) from e if isinstance(file_path_or_contents, pathlib.Path): # Check if the file exists: