diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da76761..732349b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,7 +67,6 @@ jobs: name: coverage path: .coverage.${{ matrix.python-version }}.${{ matrix.os }} - combine-coverages: name: Upload coverage report needs: [test] @@ -97,7 +96,7 @@ jobs: coverage combine coverage coverage report coverage html --show-contexts --title "RenderCV coverage for ${{ github.sha }}" - + - name: Upload coverage data to smokeshow run: | pip install smokeshow @@ -107,3 +106,32 @@ jobs: SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 50 SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + publish: + if: github.event_name == 'release' + name: Publish to PyPI + needs: [test] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Build + run: | + pip install -U build + python -m build + + - name: Check version + id: check-tag + uses: samuelcolvin/check-python-version@v4.1 + with: + version_file_path: pydantic/version.py + + - name: build + run: python -m build + + - name: Upload package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..12fe974 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,79 @@ +[project] +name = 'rendercv' +description = 'CV generator from a YAML/JSON file' +version = '0.1' +authors = [{ name = 'Sina Atalay' }] +requires-python = '>=3.10' +readme = "README.md" +dependencies = [ + 'annotated-types==0.6.0', + 'Jinja2==3.1.2', + 'phonenumbers==8.13.22', + 'pydantic==2.4.2', + 'pydantic-extra-types==2.1.0', + 'pydantic_core==2.10.1', + 'typing_extensions==4.8.0', + 'pyspellchecker==0.7.2', + 'ruamel.yaml==0.17.35', + 'email-validator==2.0.0.post2', +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.urls] +Homepage = 'https://sinaatalay.github.io/rendercv/' +Documentation = 'https://sinaatalay.github.io/rendercv/' +Source = 'https://github.com/sinaatalay/rendercv' + +[project.optional-dependencies] +docs = [ + "mkdocs", + "mkdocs-material", + "mkdocstrings-python", +] +testing = [ + "coverage", + "pytest", + "pytest-cov", +] +linting = [ + "black", + "ruff" +] + +[build-system] +requires = ['setuptools>=68.0'] +build-backend = 'setuptools.build_meta' + +[project.scripts] +rendercv = 'rendercv.rendering:main' + + +# [tool.ruff] +# line-length = 88 + +[tool.coverage.run] +source = ['rendercv'] +relative_files = true + +# [tool.coverage.report] +# precision = 2 +# exclude_lines = [ +# 'pragma: no cover', +# 'raise NotImplementedError', +# 'if TYPE_CHECKING:', +# 'if typing.TYPE_CHECKING:', +# '@overload', +# '@typing.overload', +# '\(Protocol\):$', +# 'typing.assert_never', +# 'assert_never', +# ] + +[tool.black] +color = true +line-length = 88 +experimental-string-processing = true diff --git a/rendercv/rendering.py b/rendercv/rendering.py index d0014c3..5c20047 100644 --- a/rendercv/rendering.py +++ b/rendercv/rendering.py @@ -8,6 +8,7 @@ from datetime import date import logging import time from typing import Optional +import sys from rendercv.data_model import RenderCVDataModel @@ -426,10 +427,10 @@ def run_latex(latex_file_path: str) -> str: ) except subprocess.CalledProcessError or subprocess.TimeoutExpired as e: raise RuntimeError( - "Running TinyTeX has failed with the following error:\n\n" - f'command "{e.cmd}" return with error (code {e.returncode}): {e.output}\n\n' - "If you can't find the problem, please try to re-install RenderCV, or" - " open an issue on GitHub." + "Running TinyTeX has failed with the following error:\n\ncommand" + f" \"{e.cmd}\" return with error (code {e.returncode}): {e.output}\n\nIf" + " you can't find the problem, please try to re-install RenderCV, or open" + " an issue on GitHub." ) # check if the PDF file is generated: @@ -457,3 +458,23 @@ def run_latex(latex_file_path: str) -> str: ) return output_file_path + + +def main(): + """ + This is the main function to run RenderCV. + """ + if len(sys.argv) < 2: + raise ValueError("Please provide the input file path.") + elif len(sys.argv) == 2: + input_file_path = sys.argv[1] + else: + raise ValueError( + "More than one input is provided. Please provide only one input, which is" + " the input file path." + ) + + file_path = os.path.join(os.getcwd(), input_file_path) + data = read_input_file(file_path) + output_latex_file = render_template(data) + run_latex(output_latex_file)