-
Couldn't load subscription status.
- Fork 13
Description
We, particularly vlsirtools, does plenty of generating input to, and parsing output from, external tools, particularly simulators.
We have not been great at tracking what versions of those external tools we expect to work.
This should be straightforward enough to roll in (if not to track forever).
Each simulator module has an available function, which does some kinda "dummy invocation" to check whether the external tool is available. E.g.
| def available() -> bool: |
@staticmethod
def available() -> bool:
"""Boolean indication of whether the current running environment includes the simulator executable."""
if shutil.which(NGSPICE_EXECUTABLE) is None:
return False
try:
subprocess.run(
f"{NGSPICE_EXECUTABLE} -v",
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=10,
)
except Exception:
# Indicate "not available" for any Exception. Usually this will be a `subprocess.CalledProcessError`.
return False
return True # Otherwise, installation looks good.This would be the place to parse and evaluate a version string, and compare it against known-good versions.
It may also make sense for available to return something more elaborate than bool, e.g.
class Something:
available: bool # The old return value; whether it should work or not
version: Optional[Version] # Whatever we parse from the version string, maybe a string or a few numbers. `None` if no version available. This would help report user errors, as well as our own pytest setup here
Vlsir/VlsirTools/vlsirtools/pytest.py
Line 87 in 4674c7e
| class Why(Enum): |