From d05a47ede9f8b731abc5e417bba097d5dfbd9ca6 Mon Sep 17 00:00:00 2001 From: Matt Swain Date: Thu, 21 Mar 2019 23:55:23 +0000 Subject: [PATCH] Improved OB version check in setup.py --- scripts/python/setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/python/setup.py b/scripts/python/setup.py index 7a3715688..ce6388aa5 100644 --- a/scripts/python/setup.py +++ b/scripts/python/setup.py @@ -11,6 +11,12 @@ from setuptools.command.install import install from setuptools import setup, Extension +# Range of Open Babel versions that these Python bindings are compatible with. +# A warning is displayed when compiling against an Open Babel outside this range. +min_ob_version = '2.3.0' +max_ob_version = '2.4.90' + + # Path to the directory that contains this setup.py file. base_dir = os.path.abspath(os.path.dirname(__file__)) @@ -40,8 +46,9 @@ def locate_ob(): """Try use pkgconfig to locate Open Babel, otherwise guess default location.""" try: version = pkgconfig('openbabel-2.0', '--modversion') - if not StrictVersion(version) >= StrictVersion('2.3.0'): - print('Warning: Open Babel 2.3.0 or later is required. Your version (%s) may not be compatible.' % version) + if not StrictVersion(min_ob_version) <= StrictVersion(version) <= StrictVersion(max_ob_version): + print('Warning: Open Babel %s - %s is required. Your version (%s) may not be compatible.' + % (min_ob_version, max_ob_version, version)) include_dirs = pkgconfig('openbabel-2.0', '--variable=pkgincludedir') library_dirs = pkgconfig('openbabel-2.0', '--variable=libdir') print('Open Babel location automatically determined by pkg-config:')