Summary
check_ar6_magicc7_version in src/gcages/ar6/scm_running.py catches any ImportError from import openscm_runner.adapters and reports it as a missing optional dependency:
try:
import openscm_runner.adapters # noqa: PLC0415
except ImportError as exc:
raise MissingOptionalDependencyError(
"check_ar6_magicc7_version", requirement="openscm_runner"
) from exc
ModuleNotFoundError subclasses ImportError, so a failure inside openscm_runner is reported as openscm_runner being absent.
What it looks like
On Python 3.12+, openscm_runner.adapters imports the CICERO-SCM adapter, which imports distutils — removed from the standard library in 3.12 (openscm/openscm-runner#110). With openscm_runner installed and importable, we got:
MissingOptionalDependencyError: `check_ar6_magicc7_version` requires openscm_runner to be installed
The suggested fix is to install a package that is already installed. The actual missing module is distutils, which the message never mentions. The chained __cause__ carries it, but the top-level message is what gets read and acted on — it cost us a while to get past.
Suggested fix
Distinguish "the package is absent" from "the package failed to import". For example:
try:
import openscm_runner.adapters
except ImportError as exc:
if getattr(exc, "name", None) in {"openscm_runner", None}:
raise MissingOptionalDependencyError(
"check_ar6_magicc7_version", requirement="openscm_runner"
) from exc
raise
Re-raising preserves the original message, which names distutils directly. Alternatively, keep MissingOptionalDependencyError but include str(exc) in the message.
Verified against the current release (v0.14.0).
Summary
check_ar6_magicc7_versioninsrc/gcages/ar6/scm_running.pycatches anyImportErrorfromimport openscm_runner.adaptersand reports it as a missing optional dependency:ModuleNotFoundErrorsubclassesImportError, so a failure inside openscm_runner is reported as openscm_runner being absent.What it looks like
On Python 3.12+,
openscm_runner.adaptersimports the CICERO-SCM adapter, which importsdistutils— removed from the standard library in 3.12 (openscm/openscm-runner#110). With openscm_runner installed and importable, we got:The suggested fix is to install a package that is already installed. The actual missing module is
distutils, which the message never mentions. The chained__cause__carries it, but the top-level message is what gets read and acted on — it cost us a while to get past.Suggested fix
Distinguish "the package is absent" from "the package failed to import". For example:
Re-raising preserves the original message, which names
distutilsdirectly. Alternatively, keepMissingOptionalDependencyErrorbut includestr(exc)in the message.Verified against the current release (v0.14.0).