diff --git a/conda/meta.yaml b/conda/meta.yaml index 10a2dd33..e6b3289f 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -22,6 +22,7 @@ requirements: - importlib_resources - jinja2 - lxml + - packaging - pyyaml - requests - rsync diff --git a/mache/spack/env.py b/mache/spack/env.py index ab7b12da..5473743c 100644 --- a/mache/spack/env.py +++ b/mache/spack/env.py @@ -3,6 +3,7 @@ from importlib import resources as importlib_resources from jinja2 import Template +from packaging.version import Version from mache.machine_info import MachineInfo, discover_machine from mache.spack.script import get_spack_script @@ -139,9 +140,13 @@ def make_spack_env( modules = f'{modules}\nexport TMPDIR={tmpdir}' + # Use PEP 440 parsing to strip any pre/dev/post release tags and keep only + # the base release version (e.g., "1.2.3rc1" -> "1.2.3"). + version = Version(__version__).base_version + template_args = dict( modules=modules, - version=__version__, + version=version, spack_path=spack_path, env_name=env_name, yaml_filename=yaml_filename, diff --git a/pyproject.toml b/pyproject.toml index 35f9300b..51f72466 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dependencies = [ "importlib_resources", "jinja2", "lxml", + "packaging", "pyyaml", "requests", "termcolor", diff --git a/spec-file.txt b/spec-file.txt index 15f85530..35754b9e 100644 --- a/spec-file.txt +++ b/spec-file.txt @@ -2,6 +2,7 @@ python >=3.9 importlib_resources jinja2 lxml +packaging pyyaml requests rsync