Skip to content

Commit

Permalink
support 3.8-only metadata fetching. Closes #7974
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Dec 19, 2023
1 parent 2107e4b commit ccfdc52
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/resources/capabilities/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@

def discover_package(pkg):
sys.stdout.write('\n' + pkg + ': ')
v = 'null'
try:
imp = importlib.import_module(pkg)
sys.stdout.write(str(imp.__version__))
try:
from importlib.metadata import version
v = version(pkg)
except ImportError:
imp = importlib.import_module(pkg)
v = str(imp.__version__)
except Exception:
sys.stdout.write('null')
pass
sys.stdout.write(v)

discover_package('jupyter_core')
discover_package('nbformat')
Expand Down

0 comments on commit ccfdc52

Please sign in to comment.