Skip to content

Commit 7864a06

Browse files
Add minimum shared library version check
1 parent 81f5861 commit 7864a06

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mopactools"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
authors = [
99
{ name="Jonathan Moussa", email="jemoussa@vt.edu" },
1010
]
@@ -23,6 +23,7 @@ license = { text="Apache-2.0" }
2323
dependencies = [
2424
"numpy",
2525
"scipy",
26+
"packaging",
2627
]
2728

2829
[project.urls]

src/mopactools/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import ctypes
2020
import numpy as np
2121
import scipy
22+
from packaging.version import Version, InvalidVersion
2223
from . import binding
2324

2425
class MopacSystem:
@@ -646,4 +647,9 @@ def from_file(input_path):
646647
binding.libmopac.get_mopac_version(buffer)
647648
#: Semantic version number of the MOPAC shared library
648649
VERSION = buffer.value.decode('utf-8')
649-
# In the future, it might make sense to put a minimum version test here
650+
MIN_VERSION = "23.2"
651+
try:
652+
if Version(VERSION) < Version(MIN_VERSION):
653+
raise ValueError(f"MOPAC shared library version ({VERSION}) is older than the minimum required version ({MIN_VERSION}).")
654+
except InvalidVersion:
655+
print(f"WARNING: MOPAC shared library has a non-standard version ({VERSION}) and might not be compatible with mopactools.")

0 commit comments

Comments
 (0)