Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Only import jinja2 when needed #5514

Merged
merged 7 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5513.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent python module `jinja2` from being required even though it is marked as an optional dependency.
6 changes: 4 additions & 2 deletions synapse/rest/client/v2_alpha/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import sys

from six.moves import http_client

import jinja2

from twisted.internet import defer

from synapse.api.constants import LoginType
Expand Down Expand Up @@ -309,6 +308,9 @@ def load_jinja2_template(self, template_dir, template_filename, template_vars):
Returns:
str containing the contents of the rendered template
"""
if "jinja2" not in sys.modules:
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
import jinja2

loader = jinja2.FileSystemLoader(template_dir)
env = jinja2.Environment(loader=loader)

Expand Down