Skip to content

Commit

Permalink
Replace deprecated pkg_resources usage
Browse files Browse the repository at this point in the history
Use importlib.metadata to check the jinja2 version

Signed-off-by: Cindy Liu <hcindyl@google.com>
  • Loading branch information
hcindyl authored and lsf37 committed Jun 17, 2024
1 parent f7ef9ca commit b567813
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cdl_utils/capdl_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
from capdl.Object import register_object_sizes, Untyped
from capdl.Allocator import ASIDTableAllocator, BestFitAllocator
from capdl import ELF, lookup_architecture, TCB, valid_architectures
from importlib.metadata import version
from jinja2 import Environment, BaseLoader, FileSystemLoader
import sys
import argparse
import pickle
import logging
import os
import tempfile
import pkg_resources
import yaml
import six
pkg_resources.require("jinja2>=2.10")


CSPACE_TEMPLATE_FILE = os.path.join(os.path.dirname(__file__), "templates/cspace.template.c")
Expand All @@ -29,6 +28,10 @@ def manifest(cap_symbols, region_symbols, architecture, targets):
Generates a c file from CSPACE_TEMPLATE_FILE with some runtime information
about CSpace slots and special address ranges
"""
jinja2_version = version("jinja2")
if jinja2_version < "2.10":
raise Warning("Jinja2 should be >= 2.10")

temp_file = open(CSPACE_TEMPLATE_FILE, 'r').read()
template = Environment(loader=BaseLoader).from_string(temp_file)

Expand Down

0 comments on commit b567813

Please sign in to comment.