diff --git a/metis_wizard/__init__.py b/metis_wizard/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/metis_wizard.py b/metis_wizard/metis_wizard.py
similarity index 93%
rename from metis_wizard.py
rename to metis_wizard/metis_wizard.py
index b5512d0..440b81a 100644
--- a/metis_wizard.py
+++ b/metis_wizard/metis_wizard.py
@@ -5,6 +5,7 @@
scales to approximately 300 cores. See the notes in the ``fesom`` documentation for more information.
"""
+import importlib.resources as pkg_resources
import pathlib
import shutil
import subprocess
@@ -85,7 +86,6 @@ class MetisPartitioner:
"""
_BIN = "fesom_ini"
- _NML = "namelist.config"
def __init__(self, bin: str = None) -> None:
"""
@@ -111,7 +111,7 @@ def partition_mesh(self, mesh: FesomMesh, n_part: int = 288) -> None:
n_part (int, optional): The number of partitions. Defaults to 288.
"""
# Create the namelist:
- nml = prepare_namelist(self._NML, mesh, n_part)
+ nml = prepare_namelist(mesh, n_part)
# Write the namelist:
nml.write("namelist.config", force=True)
logger.info(f"Namelist written for {self.bin}.")
@@ -121,21 +121,26 @@ def partition_mesh(self, mesh: FesomMesh, n_part: int = 288) -> None:
logger.success(f"Mesh partitioned with {self.bin} for {n_part}.")
-def prepare_namelist(nml_path: str or pathlib.Path, mesh: FesomMesh, n_part: int = 288):
+def read_namelist_config():
+ with pkg_resources.open_text("metis_wizard", "namelist.config") as file:
+ data = file.read()
+ return data
+
+
+def prepare_namelist(mesh: FesomMesh, n_part: int = 288):
"""
This function prepares the METIS namelist file for partitioning.
Parameters:
-----------
- nml_path (str): The path to the namelist file.
n_part (int, optional): The number of partitions. Defaults to 288.
Returns:
--------
MetisNamelist object: The METIS namelist object.
"""
- with open(nml_path, "r") as f:
- nml = MetisNamelist(f90nml.read(f))
+ f = read_namelist_config()
+ nml = MetisNamelist(f90nml.reads(f))
nml.set_mesh(mesh.path)
nml.set_partitioning(n_part)
return nml
diff --git a/namelist.config b/metis_wizard/namelist.config
similarity index 100%
rename from namelist.config
rename to metis_wizard/namelist.config
diff --git a/pyproject.toml b/pyproject.toml
index 4b39783..4fe98ac 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,18 +4,21 @@ version = "1.0.0"
description = ""
authors = ["Paul Gierz "]
readme = "README.md"
+include = ["metis_wizard/namelist.config"]
+packages = [
+ { include = "metis_wizard", from = "." }
+]
+
[tool.poetry.dependencies]
f90nml = "^1.4.4"
rich-click = "^1.8.3"
click-loguru = "^1.3.8"
questionary = "^2.0.1"
-
click = "^8.1.7"
[tool.poetry.scripts]
-metis-wizard = "metis_wizard:main"
-
+metis-wizard = "metis_wizard.metis_wizard:main"
[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"