jupyter_server icon indicating copy to clipboard operation
jupyter_server copied to clipboard

How to get the extension version?

Open echarles opened this issue 3 years ago • 0 comments

NbClassic uses the sys_info injected in the HTML page to show it About box. The sys_info was previously populated by this block code https://github.com/jupyter/nbclassic/blob/2f7fd12432bccfec642544eef8b6c0e9a51f6699/nbclassic/_sysinfo.py#L92-L96

Since NbClassic is now a server extension, the sys_info is populated from the jupyter_server block code https://github.com/jupyter-server/jupyter_server/blob/7d2154a1e243f80ed5fc4c067fd022e32f3fc8f0/jupyter_server/_sysinfo.py#L89-L93

The resulting json is something like



<script type="text/javascript">
--
  | sys_info = {"jupyter_server_version": "1.18.1", "jupyter_server_path": "/Users/echarles/opt/miniconda3/envs/notebook/lib/python3.9/site-packages/jupyter_server", "commit_source": "", "commit_hash": "", "sys_version": "3.9.13 \| packaged by conda-forge \| (main, May 27 2022, 17:00:52) \n[Clang 13.0.1 ]", "sys_executable": "/Users/echarles/opt/miniconda3/envs/notebook/bin/python3.9", "sys_platform": "darwin", "platform": "macOS-11.1-x86_64-i386-64bit", "os_name": "posix"};
  | </script>

To show the nbclassic version, we can not rely anymore on that information.

An option would be to directly use the setting which has a key nbclassic with the complete NotebookApp and ask from that object the version field.

{
...
    "nbclassic": <nbclassic.notebookapp.NotebookApp object at 0x10bcd54c0>,
...
}
```

That can work as we know that NotebookApp has a public version field, but this may not work for all etensions.

How should an extension get its version ?

cc/ @Zsailer 

echarles avatar Sep 14 '22 17:09 echarles