neocl / jamdict

Python 3 library for manipulating Jim Breen's JMdict, KanjiDic2, JMnedict and kanji-radical mappings
MIT License
130 stars 12 forks source link

Allow embedding precompiled dict when building exe app #16

Closed matteofumagalli1275 closed 4 years ago

matteofumagalli1275 commented 4 years ago

Hi, First of all let me say that i'm not much into python, so let me know if i'm missing or misunderstand something.

I'm building an exe application for windows using this module, since i don't want python as a requirement i wanted to ship the precompiled dictionary with the application. I could copy .jamdict during the installation, but i thought it would be better for it to be inside the bundle.

I saw that config.py tries to search for db in different directories, starting with the __file__ directory. So if i create a jamdict/ directory with jamdict.json in the folder of the executable program, it actually reads it for searching db files. Problem is that JAMDICT_HOME is ~/.jamdict by default, and if remove it i falls back to current directory folder ('.'). So it can't find the dbs.

I think JAMDICT_HOME should be fallbacking to __jamdict_home, since this is the path actually used to search for jamdict.json (as alternative to ~/.jamdict). Using this code i can bundle the precompiled dictionary successfully.

letuananh commented 4 years ago

Thank you for the pull request. I overlooked this issue. I'll update the package on PyPI soon.