From 70020208d339cabdbd0c015963bc9dfbd8c9d2dc Mon Sep 17 00:00:00 2001 From: Andrew Pontzen Date: Thu, 9 Nov 2023 20:57:54 +0000 Subject: [PATCH] Fix for python 3.9 backwards compatibility --- tangos/properties/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tangos/properties/__init__.py b/tangos/properties/__init__.py index e5298e99..7de6d3c6 100644 --- a/tangos/properties/__init__.py +++ b/tangos/properties/__init__.py @@ -2,6 +2,7 @@ import importlib import os import warnings +import sys from importlib.metadata import entry_points import numpy as np @@ -568,6 +569,12 @@ def instantiate_class(simulation, property_name, silent_fail=False): else: return instance[0] +def _get_entry_points(): + if sys.version_info >= (3, 10): + return entry_points(group='tangos.property_modules') + else: + return entry_points()['tangos.property_modules'] + def _import_configured_property_modules(): if "PYTEST_CURRENT_TEST" in os.environ: warnings.warn("Not importing external property modules during testing", ImportWarning) @@ -581,7 +588,7 @@ def _import_configured_property_modules(): except ImportError: warnings.warn("Failed to import requested property module %r. Some properties may be unavailable."%pm, ImportWarning) - for module in entry_points(group='tangos.property_modules'): + for module in _get_entry_points(): module.load() _import_configured_property_modules()