Skip to content

Commit

Permalink
add templates to package-data, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Oct 10, 2024
1 parent a7f2644 commit b66ea2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
21 changes: 0 additions & 21 deletions autotest/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@ def test_dfn_load(dfn_name):
assert any(dfn)


@pytest.mark.parametrize(
"dfn, n_vars, n_flat, n_meta",
[("gwf-ic", 2, 2, 0), ("prt-prp", 18, 40, 1)],
)
def test_make_context(dfn, n_vars, n_flat, n_meta):
with open(DFN_PATH / "common.dfn") as f:
commonvars = Dfn.load(f)

with open(DFN_PATH / f"{dfn}.dfn") as f:
dfn = DfnName(*dfn.split("-"))
definition = Dfn.load(f, name=dfn)

context_names = get_context_names(dfn)
context_name = context_names[0]
context = make_context(context_name, definition, commonvars)
assert len(context_names) == 1
assert len(context.variables) == n_vars
assert len(context.definition) == n_flat
assert len(context.definition.metadata) == n_meta


@pytest.mark.parametrize("dfn_name", DFN_NAMES)
def test_make_targets(dfn_name, function_tmpdir):
with open(DFN_PATH / "common.dfn") as f:
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/utils/codegen/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)
from warnings import warn

from jinja2 import Environment, FileSystemLoader
from jinja2 import Environment, PackageLoader

# noqa: F401
from flopy.mf6.utils.codegen.context import (
Expand All @@ -15,7 +15,7 @@
from flopy.mf6.utils.codegen.dfn import Dfn, DfnName, Dfns
from flopy.mf6.utils.codegen.ref import Ref, Refs

_TEMPLATE_LOADER = FileSystemLoader(Path(__file__).parent / "templates")
_TEMPLATE_LOADER = PackageLoader("flopy", "mf6/utils/codegen/templates/")
_TEMPLATE_ENV = Environment(loader=_TEMPLATE_LOADER)
_TEMPLATE_NAME = "context.py.jinja"
_TEMPLATE = _TEMPLATE_ENV.get_template(_TEMPLATE_NAME)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ include = ["flopy", "flopy.*"]

[tool.setuptools.package-data]
"flopy.mf6.data" = ["dfn/*.dfn"]
"flopy.mf6.utils.codegen" = ["templates/*.jinja"]
"flopy.plot" = ["mplstyle/*.mplstyle"]

[tool.ruff]
Expand Down

0 comments on commit b66ea2a

Please sign in to comment.