Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions imas/backends/imas_core/mdsplus_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import time
import uuid
from pathlib import Path
from saxonche import PySaxonProcessor
from subprocess import CalledProcessError, check_output
from zlib import crc32

Expand Down Expand Up @@ -244,11 +243,20 @@ def transform_with_xslt(xslt_processor, source, xslfile, output_file):

def create_model_ids_xml(cache_dir_path, fname, version):
"""Use Saxon/C to compile an ids.xml suitable for creating an MDSplus model."""
try:
import saxonche
except ImportError:
raise RuntimeError(
"Building mdsplus models requires the 'saxonche' python package. "
"Please install this package (for example with 'pip install saxonche') "
"and try again."
)

try:
with as_file(files("imas") / "assets" / "IDSDef2MDSpreTree.xsl") as xslfile:
output_file = Path(cache_dir_path) / "ids.xml"

with PySaxonProcessor(license=False) as proc:
with saxonche.PySaxonProcessor(license=False) as proc:
xslt_processor = proc.new_xslt30_processor()
xdm_ddgit = proc.make_string_value(str(version) or fname)
xslt_processor.set_parameter("DD_GIT_DESCRIBE", xdm_ddgit)
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
# Minimum requirements for the build system to execute.
# Keep this on a single line for the grep magic of build scripts to work
requires = ["setuptools>=61", "wheel", "numpy", "gitpython", "saxonche","packaging", "tomli;python_version<'3.11'", "setuptools_scm>8"]
requires = ["setuptools>=61", "wheel", "numpy", "packaging", "tomli;python_version<'3.11'", "setuptools_scm>8"]

build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -63,8 +63,6 @@ dependencies = [
"importlib_resources;python_version<'3.9'",
"packaging",
"xxhash >= 2",
"saxonche",
"gitpython",
"imas_data_dictionaries",
]

Expand Down Expand Up @@ -92,6 +90,9 @@ h5py = [
xarray = [
"xarray",
]
saxonche = [
"saxonche",
]
test = [
"pytest>=5.4.1",
"pytest-cov>=0.6",
Expand All @@ -101,11 +102,11 @@ test = [
"asv == 0.6.1",
# virtualenv is a dependency of asv
"virtualenv",
# Pint and xarray are used in training snippets
# Pint is used in training snippets
"pint",
# Optional dependencies
# TODO add imas-core when it is available on pypi
"imas-python[netcdf,h5py,xarray]",
"imas-python[netcdf,h5py,xarray,saxonche]",
]

[project.scripts]
Expand Down
Loading