diff --git a/pyproject.toml b/pyproject.toml index 169146e..04e9b65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,3 +32,7 @@ pygitver = "pygitver.pygitver:main" [metadata] url = "https://github.com/panpuchkov/pygitver" + + +[tool.setuptools.package-data] +pygitver = ["*.py", "*.tmpl"] diff --git a/src/pygitver/changelogs_mngr.py b/src/pygitver/changelogs_mngr.py index dcc2f48..991d1ed 100644 --- a/src/pygitver/changelogs_mngr.py +++ b/src/pygitver/changelogs_mngr.py @@ -1,4 +1,5 @@ import os +import pathlib import json from pygitver.git import Git, GitError @@ -51,9 +52,10 @@ def read_files(self, path: str, file_ext: str = "json"): def generate(self, template_name: str = "") -> str: if not template_name: + script_directory = pathlib.Path(__file__).parent.resolve() template_name = os.getenv( "PYGITVER_TEMPLATE_CHANGELOG_COMMON", - "pygitver/templates/changelog-common.tmpl", + f"{script_directory}/templates/changelog-common.tmpl", ) try: env = Environment(loader=FileSystemLoader(os.path.dirname(template_name))) diff --git a/src/pygitver/git.py b/src/pygitver/git.py index 9c420a6..40fc0e3 100644 --- a/src/pygitver/git.py +++ b/src/pygitver/git.py @@ -1,5 +1,6 @@ -import json import os +import pathlib +import json import re import subprocess from jinja2 import Environment, FileSystemLoader, TemplateNotFound @@ -252,8 +253,10 @@ def changelog_generate(changelog_group: dict, template_name: str = "") -> str: :return: string with formatted changelog """ if not template_name: + script_directory = pathlib.Path(__file__).parent.resolve() template_name = os.getenv( - "PYGITVER_TEMPLATE_CHANGELOG", "templates/changelog.tmpl" + "PYGITVER_TEMPLATE_CHANGELOG", + f"{script_directory}/templates/changelog.tmpl", ) try: env = Environment(loader=FileSystemLoader(os.path.dirname(template_name)))