Skip to content

Commit

Permalink
Support older Jinja2 installs required by some applications
Browse files Browse the repository at this point in the history
  • Loading branch information
MHendricks committed Apr 21, 2023
1 parent d9b58ea commit 2d2936d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ You can administratively default the execution policy to unrestricted for window
* To use `hab activate` in bash or Powershell you need to use `.` or `source`. Powershell
has the `.` operator so I would use that for both Powershell and bash.
`. hab activate default`.
* Jinja2 and MarkupSafe minimum requirements should be respected. This allows hab
to work with Houdini 19.5 that ships with very dated versions of these packages.
In practice this just means that we have to cast pathlib objects to strings before
passing them to Jinja2.

# Glosary

Expand Down
8 changes: 6 additions & 2 deletions hab/parsers/hab_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ def generate_config_script(
"""

environment = Environment(
loader=FileSystemLoader(TEMPLATES), trim_blocks=True, lstrip_blocks=True
loader=FileSystemLoader(str(TEMPLATES)),
trim_blocks=True,
lstrip_blocks=True,
)
template = environment.get_template(f"{template}{ext}")
kwargs = dict(
Expand Down Expand Up @@ -624,7 +626,9 @@ def generate_alias_script(self, template, ext, alias, cfg):
str: The rendered script.
"""
environment = Environment(
loader=FileSystemLoader(TEMPLATES), trim_blocks=True, lstrip_blocks=True
loader=FileSystemLoader(str(TEMPLATES)),
trim_blocks=True,
lstrip_blocks=True,
)
template = environment.get_template(f"{template}{ext}")
kwargs = dict(
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ anytree
click>=7.1.2
colorama
future>=0.18.2
Jinja2
Jinja2>=2.10.1
MarkupSafe>=0.23
packaging>=20.0
Pygments
setuptools>=44.1.1
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ project_urls =
[options]
packages = find:
install_requires =
Jinja2
Jinja2>=2.10.1
MarkupSafe>=0.23
Pygments
anytree
click>=7.1.2
Expand Down
4 changes: 3 additions & 1 deletion tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def check_file(item):
# Using Jinja for this because other python str formatting methods require
# too much manipulation of the reference files.
environment = Environment(
loader=FileSystemLoader(item.parent), trim_blocks=True, lstrip_blocks=True
loader=FileSystemLoader(str(item.parent)),
trim_blocks=True,
lstrip_blocks=True,
)
template = environment.get_template(item.name)
# Note: jinja2' seems to be inconsistent with its trailing newlines depending
Expand Down

0 comments on commit 2d2936d

Please sign in to comment.