diff --git a/scanpy/_metadata.py b/scanpy/_metadata.py index e5acb09460..fa631793d2 100644 --- a/scanpy/_metadata.py +++ b/scanpy/_metadata.py @@ -3,6 +3,23 @@ here = Path(__file__).parent + +def refresh_entry_points(): + """\ + Under some circumstances, (e.g. when installing a PEP 517 package via pip), + pkg_resources.working_set.entries is stale. This tries to fix that. + """ + try: + import sys + import pkg_resources + + ws: pkg_resources.WorkingSet = pkg_resources.working_set + for entry in sys.path: + ws.add_entry(entry) + except Exception: + pass + + try: from setuptools_scm import get_version import pytoml @@ -10,6 +27,7 @@ proj = pytoml.loads((here.parent / 'pyproject.toml').read_text()) metadata = proj['tool']['flit']['metadata'] + refresh_entry_points() __version__ = get_version(root='..', relative_to=__file__) __author__ = metadata['author'] __email__ = metadata['author-email']