mocobeta / janome

Japanese morphological analysis engine written in pure Python
https://mocobeta.github.io/janome/en/
Apache License 2.0
856 stars 51 forks source link

Add version information into ` __init__.py` #91

Closed norihitoishida closed 3 years ago

norihitoishida commented 3 years ago

Hello @mocobeta and janome-contributors ! Thank you for developing such a great library.

I am using janome in an interactive environment like jupyter-lab.

I'd be very happy if janome.__version__ could show the version, like other major libraries (Numpy, statsmodels, PyTorch, Optuna, etc.). This could be achieved by modifying __init__.py.

It would also be beneficial to import classes such as Tokenizer inside __init__.py, so that the dir(janome) shows what classes are below it.

However, this also has the disadvantage of increasing the time and memory usage of import janome.

What are the opinions of developers regarding the implementation of this? If there are no problems, I would like to send a pull request.

Best regard.

mocobeta commented 3 years ago

Hi @norihitoishida, I am not familiar with the __version__ property. Can you point the specification/example for that, or make a patch?

FWIW, we already have version.py file that holds the version information and bundled janome command shows it by --version option. However I'm not against changing it if there's a standard way to manage the version info. https://github.com/mocobeta/janome/commit/ee3855b6014477f18f6c39114f15a6d084a94c5

norihitoishida commented 3 years ago

Thanks for the quick response @mocobeta !

PEP 8 and PEP 396 recommend the use of __version__ property. As naive implementation, how about changing __init__.py like this?

from janome.version import JANOME_VERSION as __version__
>>> import janome
>>> janome.__version__
'0.4.1'

Reference

Examples

mocobeta commented 3 years ago

Thanks for the pointers,

from janome.version import JANOME_VERSION as version

It sounds good to me (I don't think we need more complex implementations as libraries listed there)!

norihitoishida commented 3 years ago

Thank you so much :)