Skip to content

Commit

Permalink
Move templates to api directory
Browse files Browse the repository at this point in the history
In order to access templates while running API from python
package, move `templates` to `api` directory.
Update `pyproject.toml` to include `api/templates` directory
to the python package.
Update `api.user_manager` to use `PackageLoader` to load
templates from the python package.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia authored and nuclearcat committed Feb 26, 2024
1 parent fca8b1f commit b9cbf40
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._email_sender = None
self._template_env = jinja2.Environment(
loader=jinja2.FileSystemLoader("./templates/")
loader=jinja2.PackageLoader("api", "templates")
)

@property
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Documentation = "https://kernelci.org/docs"
Repository = "https://github.com/kernelci/kernelci-api"

[tool.setuptools]
packages = ["api", "scripts", "templates"]
packages = ["api", "scripts", "api.templates"]

[tool.setuptools.package-data]
scripts = ["*"]
templates = ["*.jinja2", "*.html"]
"api.templates" = ["*.jinja2", "*.html"]

0 comments on commit b9cbf40

Please sign in to comment.