Skip to content

Commit

Permalink
Fix for python 3.9 backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
apontzen committed Nov 9, 2023
1 parent 3c433d4 commit 7002020
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tangos/properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib
import os
import warnings
import sys
from importlib.metadata import entry_points

import numpy as np
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 7002020

Please sign in to comment.