Skip to content

Commit

Permalink
Make jinja2 an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed Oct 30, 2024
1 parent 1343a6e commit bd7f058
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 0 additions & 5 deletions dace/cli/dacelab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.

import argparse
import numpy
import pickle
import json

import dace
from dace.frontend.octave import parse
from dace.sdfg.nodes import AccessNode

Expand Down
6 changes: 5 additions & 1 deletion dace/cli/sdfg_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import tempfile
from typing import Dict, Literal, Set, Tuple, Union

import jinja2
import dace
from dace import memlet as mlt
from dace.sdfg import nodes as nd
Expand Down Expand Up @@ -179,6 +178,11 @@ def main():
diff_sets = _sdfg_diff(sdfg_A, sdfg_B, eq_strategy)

if args.graphical:
try:
import jinja2
except (ImportError, ModuleNotFoundError):
raise ImportError('Graphical SDFG diff requires jinja2, please install by running `pip install jinja2`')

basepath = os.path.join(os.path.dirname(os.path.realpath(dace.__file__)), 'viewer')
template_loader = jinja2.FileSystemLoader(searchpath=os.path.join(basepath, 'templates'))
template_env = jinja2.Environment(loader=template_loader)
Expand Down
6 changes: 5 additions & 1 deletion dace/cli/sdfv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import dace
import tempfile
import jinja2


def partialclass(cls, *args, **kwds):
Expand All @@ -35,6 +34,11 @@ def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: b
blocking the current thread.
:param verbose: Be verbose.
"""
try:
import jinja2
except (ImportError, ModuleNotFoundError):
raise ImportError('SDFG.view() requires jinja2, please install by running `pip install jinja2`')

# If vscode is open, try to open it inside vscode
if filename is None:
if (
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
include_package_data=True,
install_requires=[
'numpy < 2.0', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply', 'websockets', 'jinja2',
'numpy < 2.0', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply',
'fparser >= 0.1.3', 'aenum >= 3.1', 'dataclasses; python_version < "3.7"', 'dill',
'pyreadline;platform_system=="Windows"', 'typing-compat; python_version < "3.8"', 'packaging'
] + cmake_requires,
Expand Down

0 comments on commit bd7f058

Please sign in to comment.