Skip to content

Commit

Permalink
Circumvent setuptools bug
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jan 18, 2021
1 parent ee8c384 commit c622322
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scanpy/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@

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

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']
Expand Down

0 comments on commit c622322

Please sign in to comment.