Skip to content

Commit 1bd541f

Browse files
Use jinja2 FileSystemLoader instead of PackageLoader for compat with newer meson-python and editable installs
Co-Authored-By: Will Ayd <[email protected]>
1 parent 1bd75cc commit 1bd541f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pandas/io/formats/style_render.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Sequence,
77
)
88
from functools import partial
9+
import pathlib
910
import re
1011
from typing import (
1112
TYPE_CHECKING,
@@ -70,7 +71,9 @@ class StylerRenderer:
7071
Base class to process rendering a Styler with a specified jinja2 template.
7172
"""
7273

73-
loader = jinja2.PackageLoader("pandas", "io/formats/templates")
74+
this_dir = pathlib.Path(__file__).parent.resolve()
75+
template_dir = this_dir / "templates"
76+
loader = jinja2.FileSystemLoader(template_dir)
7477
env = jinja2.Environment(loader=loader, trim_blocks=True)
7578
template_html = env.get_template("html.tpl")
7679
template_html_table = env.get_template("html_table.tpl")

pandas/tests/io/formats/style/test_html.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pathlib
12
from textwrap import (
23
dedent,
34
indent,
@@ -18,7 +19,9 @@
1819

1920
@pytest.fixture
2021
def env():
21-
loader = jinja2.PackageLoader("pandas", "io/formats/templates")
22+
project_dir = pathlib.Path(__file__).parent.parent.parent.parent.parent.resolve()
23+
template_dir = project_dir / "io" / "formats" / "templates"
24+
loader = jinja2.FileSystemLoader(template_dir)
2225
env = jinja2.Environment(loader=loader, trim_blocks=True)
2326
return env
2427

0 commit comments

Comments
 (0)