buruzaemon / natto-py

natto-py combines the Python programming language with MeCab, the part-of-speech and morphological analyzer for the Japanese language.
BSD 2-Clause "Simplified" License
92 stars 13 forks source link

Documentation notes for GitHub actions #126

Open jzohrab opened 10 months ago

jzohrab commented 10 months ago

Hello, thanks (again) for this library.

I'm using this as part of my project, and in my github actions to test my project I had to sort some things out for the tests to pass, related to natto-py configuration. I thought I'd let you know, I don't know if you'd want to update the README or anything (or have me issue a PR).

Here is a snippet of the working github action yml:

  base-ci:

    runs-on: ubuntu-latest
    steps:

    - name: Install Dependencies
      run: |
        sudo apt-get update -y
        sudo apt-get install -y mecab mecab-ipadic-utf8

     ... etc etc ...

    - name: Test
      run: |
        # Have to explicitly set MECAB_PATH for natto-py.
        export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2
        pytest

This worked, at least, it does for now with github actions. The above path is where apt-get installs the library.

I used dummy steps to find the paths, e.g.:

        echo readlink:
        readlink -f /usr/bin/mecab
        actual=`readlink -f /usr/bin/mecab`
        ldd $actual

# gave me:

readlink:
/usr/bin/mecab
    linux-vdso.so.1 (0x00007ffd280a8000)
    libmecab.so.2 => /lib/x86_64-linux-gnu/libmecab.so.2 (0x00007f9fe7cdf000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9fe7a00000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9fe7600000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9fe7919000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9fe7dc4000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9fe7cbb000)

and setting the charset to anything gave parsing errors, the default worked fine.

Cheers and thanks, jz

buruzaemon commented 10 months ago

@jzohrab thanks for contacting me to let me know about possible issues with Github actions.

However, there's no explanation of what the problem actually entails, no any steps for reproducing it. If you think this directly involves natto-py, then could you please provide that information?

jzohrab commented 10 months ago

It’s mecab and not nattonpy, but in case anyone has a project using nattopy that also uses GitHub actions above are the mecab path notes. Took me a bit of time to sort out, I thought it might save someone else time as well.

perhaps the action yml snippet would be helpful … I could open a short PR if you’d like, but no problem if not.

thank you! Jz

jzohrab commented 10 months ago

Ah sorry the issue this solved just for GitHub action runs was that nattopy couldn’t find the config file automatically.