miurahr / pykakasi

Lightweight converter from Japanese Kana-kanji sentences into Kana-Roman.
https://codeberg.org/miurahr/pykakasi
GNU General Public License v3.0
421 stars 54 forks source link

kakasi command line -v option no longer works. #108

Closed denny-vandenberg closed 4 years ago

denny-vandenberg commented 4 years ago

Describe the bug Command line kakasi replacement doesn't support -v command line option. This same issue breaks the -h option as well.

To Reproduce Steps to reproduce the behavior: (example)

  1. Prepare test data attached as 'file' in current directory.
  2. Run following code with python3.
$ pip3 install pykakasi
Collecting pykakasi
  Using cached https://files.pythonhosted.org/packages/bb/59/e09e7b0e0b5aaaefa8ea6dced1fc1e60987e4663d9c4aca0a9a95a9e0ecd/pykakasi-2.0.1-py3-none-any.whl
Requirement already satisfied: klepto in ./.local/lib/python3.7/site-packages (from pykakasi) (0.2.0)
Requirement already satisfied: dill>=0.3.3 in ./.local/lib/python3.7/site-packages (from klepto->pykakasi) (0.3.3)
Requirement already satisfied: pox>=0.2.9 in ./.local/lib/python3.7/site-packages (from klepto->pykakasi) (0.2.9)
Installing collected packages: pykakasi
Successfully installed pykakasi-2.0.1
$ kakasi -v
Traceback (most recent call last):
  File "/home/dennyvandenberg/.local/bin/kakasi", line 99, in <module>
    sys.exit(main())
  File "/home/dennyvandenberg/.local/bin/kakasi", line 66, in main
    show_version()
  File "/home/dennyvandenberg/.local/bin/kakasi", line 11, in show_version
    print("{}: version {}".format(os.path.basename(sys.argv[0]),  pykakasi.__version__))
AttributeError: module 'pykakasi' has no attribute '__version__'

Expected behavior For the command to print out the version number.

Environment (please complete the following information):

miurahr commented 4 years ago

Does #109 work for you?

$ kakasi -v
pykakasi v2.0.2.dev13 on Python 3.8.5 [CPython GCC 9.3.0]
denny-vandenberg commented 4 years ago

So, #109 doesn't seem to work with python 3.7. For python 3.7, metadata doesn't appear to exist inside importlib. If I install pip3 install importlib-metadata and use the behavior from https://github.com/miurahr/pykakasi/commit/f1a2d16e1acec80f3771d285bf90d4394719792b specifically the following: try: from importlib import metadata as importlib_metadata # noqa except ImportError: import importlib_metadata

after that modification it appears to work.

miurahr commented 4 years ago

Thank you for feedback. v2.0.4 is out with suggested modifications.

denny-vandenberg commented 4 years ago

It works perfectly, thanks!