deathbeds / importnb

notebook files as source
https://importnb.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
68 stars 5 forks source link

Version not easily accessible #134

Closed bollwyvl closed 2 years ago

bollwyvl commented 2 years ago

The version of the package is not easy to test from the outside with the CLI ...

importnb --version

or at runtime...

import importnb
assert importnb.__version__ == '0.8.0'

Having one of these would be helpful for downstreams :heart_eyes:

bollwyvl commented 2 years ago

This works:

python -c "v = __import__('importnb._version')._version.__version__; print(v); assert v == '{{ version }}'"

Not doing the _version import yielded some complaints, as it doesn't seem the * import of _version "sticks".

As a further smoke test, tried run -c:

importnb run -c 'v = __import__('\''importnb._version'\'')._version.__version__; print(v); assert v == '\''0.8.0'\'''

Saw:

Traceback (most recent call last):
  File "/tmp/env/bin/importnb", line 10, in <module>
    sys.exit(main())
  File "/tmp/env/lib/python3.10/site-packages/importnb/__main__.py", line 7, in main
    Notebook.load_argv(argv)
  File "/tmp/env/lib/python3.10/site-packages/importnb/loader.py", line 294, in load_argv
    raise ValueError(f"Expected one file to execute, but received {L}.")
ValueError: Expected one file to execute, but received 3.