Skip to content

Commit

Permalink
Merge 244231c into cb47789
Browse files Browse the repository at this point in the history
  • Loading branch information
minhoryang committed Nov 14, 2019
2 parents cb47789 + 244231c commit ad73917
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 29 deletions.
49 changes: 24 additions & 25 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,68 @@ Installation
.. note::

For troubleshooting information, see these pages:
`Linux <https://github.com/konlpy/konlpy/issues?q=label%3Alinux>`_.
`Mac OS <https://github.com/konlpy/konlpy/issues?q=label%3A"mac+os">`_.
`Windows <https://github.com/konlpy/konlpy/issues?q=label%3Awindows>`_.
`Linux <https://github.com/konlpy/konlpy/issues?q=label%3AOS%2FLinux>`_.
`Mac OS <https://github.com/konlpy/konlpy/issues?q=label%3AOS%2FMacOS>`_.
`Windows <https://github.com/konlpy/konlpy/issues?q=label%3AOS%2FWindows>`_.
Please record a `"New Issue" <https://github.com/konlpy/konlpy/issues/new>`_ if you have an error that is not listed.

.. Warning::

Python 2 End of Life Announced as January 1st 2020.

This page covers Python 3 only. The last-known version for Python 2 is v0.5.2, install it via `pip install konlpy==v0.5.2`.


Ubuntu
------

Supported: Xenial(16.04.3 LTS), Bionic(18.04.3 LTS), Disco(19.04), Eoan(19.10)

1. Install dependencies

.. sourcecode:: bash

# Install Java 1.7 or up
$ sudo apt-get install g++ openjdk-7-jdk python-dev python3-dev
# Install Java 1.8 or up
$ sudo apt-get install g++ openjdk-8-jdk python3-dev python3-pip curl

2. Install KoNLPy

.. sourcecode:: bash

$ pip install konlpy # Python 2.x
$ pip3 install konlpy # Python 3.x
$ python3 -m pip install --upgrade pip
$ python3 -m pip install konlpy # Python 3.x

3. Install MeCab (*optional*)

.. sourcecode:: bash

$ sudo apt-get install curl
$ sudo apt-get install curl git
$ bash <(curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh)


CentOS
------

Supported: CentOS 7, 8

1. Install dependencies

.. sourcecode:: bash

$ sudo yum install gcc-c++ java-1.7.0-openjdk-devel python-devel

$ wget http://peak.telecommunity.com/dist/ez_setup.py # Python 2.x
$ sudo python ez_setup.py
$ sudo easy_install pip

$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz # Python 3.x
$ tar xf Python-3.*
$ cd Python-3.*
$ ./configure
$ make # Build
$ sudo make altinstall
$ sudo yum install gcc-c++ java-1.8.0-openjdk-devel python3 python3-devel python3-pip make diffutils

2. Install KoNLPy

.. sourcecode:: bash

$ pip install konlpy # Python 2.x
$ pip3.4 install konlpy # Python 3.x
$ python3 -m pip install --upgrade pip
$ python3 -m pip install konlpy # Python 3.x

3. Install MeCab (*optional*)

.. sourcecode:: bash

$ sudo yum install curl
$ sudo yum install curl git
$ bash <(curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh)


Expand All @@ -77,8 +76,8 @@ Mac OS

.. sourcecode:: bash

$ pip install konlpy # Python 2.x
$ pip3 install konlpy # Python 3.x
$ python3 -m pip install --upgrade pip
$ python3 -m pip install konlpy # Python 3.x

2. Install MeCab (*optional*)

Expand Down
15 changes: 15 additions & 0 deletions scripts/Dockerfile.centos:7
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM centos:7

RUN yum install --assumeyes gcc-c++ python3 python3-devel python3-pip java-1.8.0-openjdk-devel make diffutils
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install konlpy

RUN yum install --assumeyes curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN yum install --assumeyes git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN python3 -m pip install -r requirements-dev.txt
CMD python3 -m pytest -v .
15 changes: 15 additions & 0 deletions scripts/Dockerfile.centos:8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM centos:8

RUN yum install --assumeyes gcc-c++ python3 python3-devel python3-pip java-1.8.0-openjdk-devel make diffutils
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install konlpy

RUN yum install --assumeyes curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN yum install --assumeyes git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN python3 -m pip install -r requirements-dev.txt
CMD python3 -m pytest -v .
17 changes: 17 additions & 0 deletions scripts/Dockerfile.ubuntu:bionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:bionic

RUN apt-get update

RUN apt-get install -y g++ openjdk-8-jdk python3-dev python3-pip
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install konlpy

RUN apt-get install -y curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN apt-get install -y git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN python3 -m pip install -r requirements-dev.txt
CMD python3 -m pytest -v .
17 changes: 17 additions & 0 deletions scripts/Dockerfile.ubuntu:disco
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:disco

RUN apt-get update

RUN apt-get install -y g++ openjdk-8-jdk python3-dev python3-pip
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install konlpy

RUN apt-get install -y curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN apt-get install -y git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN python3 -m pip install -r requirements-dev.txt
CMD python3 -m pytest -v .
17 changes: 17 additions & 0 deletions scripts/Dockerfile.ubuntu:eoan
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:eoan

RUN apt-get update

RUN apt-get install -y g++ openjdk-8-jdk python3-dev python3-pip
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install konlpy

RUN apt-get install -y curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN apt-get install -y git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN python3 -m pip install -r requirements-dev.txt
CMD python3 -m pytest -v .
17 changes: 17 additions & 0 deletions scripts/Dockerfile.ubuntu:xenial
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:xenial

RUN apt-get update

RUN apt-get install -y g++ openjdk-8-jdk python3-dev python3-pip
RUN python3 -m pip install --upgrade pip
RUN pip3 install konlpy

RUN apt-get install -y curl git
RUN curl -s https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh | bash

RUN apt-get install -y git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN pip3 install -r requirements-dev.txt
CMD python3 -m pytest -v .
16 changes: 16 additions & 0 deletions scripts/Dockerfile.ubuntu:xenial-testpypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:xenial

RUN apt-get update

RUN apt-get install -y g++ openjdk-8-jdk python3-dev python3-pip
RUN pip3 install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ konlpy==0.5.2-rc.2

RUN apt-get install -y curl git
RUN curl -s https://raw.githubusercontent.com/minhoryang/konlpy/issues/271/scripts/mecab.sh | bash

RUN apt-get install -y git
RUN git clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git
RUN git checkout master
RUN pip3 install -r requirements-dev.txt
CMD python3 -m pytest -v .
29 changes: 29 additions & 0 deletions scripts/Dockerfile.windows:10
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM mcr.microsoft.com/windows:1809

# Install Chocolatey
RUN @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

# New Powershell, so choco is available
SHELL ["powershell"]

# Choco disable upload progress
RUN choco feature disable --name showDownloadProgress

# python 3.
RUN choco install -y python3
RUN py -m pip install --upgrade pip

# Jpype requires: (and respect caching)
RUN choco install -y vcbuildtools # XXX: so long...
RUN choco install -y adoptopenjdk11 --version 11.0.5.10 # XXX: version fixed for JAVA_HOME.
ENV JAVA_HOME "C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.5.10-hotspot"

# TestEnv
RUN choco install -y git.install
RUN & 'C:\Program Files\Git\bin\git.exe' clone https://github.com/konlpy/konlpy konlpy.git
WORKDIR konlpy.git

RUN & 'C:\Program Files\Git\bin\git.exe' checkout master
RUN py -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ konlpy==0.5.2-rc.2
RUN py -m pip install -r .\requirements-dev.txt
CMD py -m pytest -v .
42 changes: 38 additions & 4 deletions scripts/mecab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ else
sudo=""
fi

# Determine python
# TODO: Prefer python3 and Respect pyenv
python="python3"
if hash "pyenv" &>/dev/null; then
python="python"
fi

# Determine python site location are writable.
check_python_site_location_is_writable(){
$python - <<EOF
import site, os
found = False
for dir in site.getsitepackages():
if not os.path.isdir(dir):
continue
if os.access(dir, os.W_OK | os.X_OK):
found = True
break
print(1 if found else 0)
EOF
}
at_user_site=""
if [[ "$(check_python_site_location_is_writable)" == "0" ]]; then
at_user_site="--user"
fi

install_mecab_ko(){
cd /tmp
curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz
Expand All @@ -54,7 +80,7 @@ install_automake(){
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
$sudo apt-get update && $sudo apt-get install -y automake
elif [ "$(grep -Ei 'fedora|redhat' /etc/*release)" ]; then
$sudo yum install -y automake
$sudo yum install -y automake diffutils make
else
##
# Autoconf
Expand Down Expand Up @@ -98,6 +124,11 @@ install_automake(){
fi

elif [ "$os" == "Darwin" ]; then
if [[ $(command -v brew) == "" ]]; then
echo "This script require Homebrew!"
echo "Try https://brew.sh/"
exit 0
fi
brew install automake
fi
}
Expand All @@ -110,7 +141,10 @@ install_mecab_ko_dic(){
cd mecab-ko-dic-2.1.1-20180720
./autogen.sh
./configure
$sudo ldconfig
if [[ $os == "Linux" ]]; then
mecab-config --libs-only-L | $sudo tee /etc/ld.so.conf.d/mecab.conf # XXX: Resolve #271, #182, #133
$sudo ldconfig
fi
make
$sudo sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc'
$sudo make install
Expand All @@ -122,7 +156,7 @@ install_mecab_python(){
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git
fi
popd
pip install /tmp/mecab-python-0.996
$python -m pip install $at_user_site /tmp/mecab-python-0.996
}


Expand All @@ -145,7 +179,7 @@ else
install_mecab_ko_dic
fi

if [[ $(python -c 'import pkgutil; print(1 if pkgutil.find_loader("MeCab") else 0)') == "1" ]]; then
if [[ $($python -c 'import pkgutil; print(1 if pkgutil.find_loader("MeCab") else 0)') == "1" ]]; then
echo "mecab-python is already installed"
else
echo "Install mecab-python"
Expand Down

0 comments on commit ad73917

Please sign in to comment.