Skip to content

Commit

Permalink
Check os compatibility and dependencies version in prepare_env.sh (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
acezen committed Jan 26, 2021
1 parent 15ce6fd commit 6865c1b
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 22 deletions.
11 changes: 7 additions & 4 deletions README.md
Expand Up @@ -18,17 +18,20 @@ Read more in the [whitepaper](https://github.com/alibaba/GraphScope/blob/main/do

## Getting Started

GraphScope can run on clusters managed by [Kubernetes](https://kubernetes.io/) within containers. For quickly getting started, we can leverage [minikube](https://minikube.sigs.k8s.io/) (on Linux) to set up a *local* Kubernetes cluster and take advantage of pre-built Docker images as follows.
GraphScope can run on clusters managed by [Kubernetes](https://kubernetes.io/) within containers. For quickly getting started, we can set up a *local* Kubernetes cluster and take advantage of pre-built Docker images as follows.

### Prerequisites

To run GraphScope on your local computer with minikube, the following dependencies or tools are required.
To run GraphScope on your local computer, the following dependencies or tools are required.

- Docker
- minikube
- Python >= 3.6 (with pip)
- Local Kubernetes cluster set-up tool (e.g. [Minikube](https://minikube.sigs.k8s.io) or [Kind](https://kind.sigs.k8s.io))

For Linux distributions, we provide a script to install the above dependencies and prepare the environment.
On Windows and macOS, you can follow the official guides to install them.
For Ubuntu/CentOS Linux distributions, we provide a script to install the above
dependencies and prepare the environment.
Alternatively, you may want to install `WSL2 <https://docs.microsoft.com/zh-cn/windows/wsl/install-win10>`_ on Windows to use the script.

```bash
# run the environment preparing script.
Expand Down
21 changes: 10 additions & 11 deletions docs/installation.rst
@@ -1,23 +1,22 @@
Installation
============

The client of GraphScope is distributed as a Python package. It manages a set of
backend engines and the coordinator via containers.
The client of GraphScope is distributed as a Python package. It manages a set of
backend engines and the coordinator via containers.

In practice, GraphScope runs on clusters managed by Kubernetes.
For quickly getting started, we can leverage `minikube <https://minikube.sigs.k8s.io/>`_
to set up a local Kubernetes cluster and take advantage of pre-built Docker images as follows.
In practice, GraphScope runs on clusters managed by Kubernetes.
For quickly getting started, we set up a local Kubernetes cluster and take advantage of pre-built Docker images as follows.

To run GraphScope on your local computer, the following dependencies or tools are required.

- Docker
- minikube
- Python 3.8 (with pip)
- Local Kubernetes cluster set-up tool (e.g. [Minikube](https://minikube.sigs.k8s.io) or [Kind](https://kind.sigs.k8s.io))

On Windows and macOS, you can follow the official guides to install them.
For Linux distributions, we provide a script to install the above
dependencies and prepare the environment.
Alternatively, You may want to install `WSL2 <https://docs.microsoft.com/zh-cn/windows/wsl/install-win10>`_ on Windows to use the scripts.
On Windows and macOS, you can follow the official guides to install them.
For Ubuntu/CentOS Linux distributions, we provide a script to install the above
dependencies and prepare the environment.
Alternatively, you may want to install `WSL2 <https://docs.microsoft.com/zh-cn/windows/wsl/install-win10>`_ on Windows to use the script.

.. code:: bash
Expand All @@ -43,7 +42,7 @@ If you have the :code:`.wheel` package, you can install the package using
pip install graphscope-0.1.macosx-10.14-x86_64.tar.gz
To build the package from source code, please download the latest version
To build the package from source code, please download the latest version
from our `repo <https://github.com/alibaba/GraphScope.git>`_ with git:

.. code:: shell
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/installation.rst
Expand Up @@ -3,16 +3,16 @@
GraphScope 客户端以 Python 程序包的形式发布,背后通过容器机制管理一组引擎和一个协调器。

GraphScope 被设计为运行在 Kubernetes 管理的群集上。
方便起见,我们可以按照本文档的以下步骤通过 `minikube <https://minikube.sigs.k8s.io/>`_ 部署一个本地 Kubernetes 集群,并加载预编译好的镜像。
方便起见,我们可以按照本文档的以下步骤部署一个本地 Kubernetes 集群,并加载预编译好的镜像。

本地运行 GraphScope 需要预先安装以下依赖。

- Docker
- minikube
- Python 3.8 (with pip)
- Local Kubernetes cluster set-up tool (e.g. [Minikube](https://minikube.sigs.k8s.io) or [Kind](https://kind.sigs.k8s.io))

对于 Windows 和 MacOS 的用户,可通过官方文档来安装上述依赖。
对于常见的 Linux 发行版用户,我们提供了脚本来准备运行时环境。
对于Ubuntu/CentOS Linux 发行版用户,我们提供了脚本来准备运行时环境。
您也可以在 Windows 上安装 `WSL2 <https://docs.microsoft.com/zh-cn/windows/wsl/install-win10>`_ 以使用脚本。

.. code:: bash
Expand Down
79 changes: 75 additions & 4 deletions scripts/prepare_env.sh
Expand Up @@ -9,7 +9,6 @@ set -o pipefail
graphscope_home="$( cd "$(dirname "$0")/.." >/dev/null 2>&1 ; pwd -P )"
version=$(cat ${graphscope_home}/VERSION)

platform=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
is_in_wsl=false && [[ ! -z "${IS_WSL}" || ! -z "${WSL_DISTRO_NAME}" ]] && is_in_wsl=true

##########################
Expand All @@ -19,6 +18,75 @@ is_in_wsl=false && [[ ! -z "${IS_WSL}" || ! -z "${WSL_DISTRO_NAME}" ]] && is_in_
# Arguments:
# None
##########################

# https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script
function get_os_version() {
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
platform="${NAME}"
os_version="${VERSION_ID}"
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
platform=$(lsb_release -si)
os_version=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
platform="${DISTRIB_ID}"
os_version="${DISTRIB_RELEASE}"
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
platform=Debian
os_version=$(cat /etc/debian_version)
elif [ -f /etc/centos-release ]; then
# Older Red Hat, CentOS, etc.
platform=CentOS
os_version=$(cat /etc/centos-release | sed 's/.* \([0-9]\).*/\1/'))
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
platform=$(uname -s)
os_version=$(uname -r)
fi
}

function check_os_compatibility() {
if [[ "${is_in_wsl}" == true && -z "${WSL_INTEROP}" ]]; then
echo "GraphScope not support to run on WSL1, please use WSL2."
exit 1
fi

if [[ "${platform}" != *"Ubuntu"* && "${platform}" != *"CentOS"* ]]; then
echo "This script is only available on Ubuntu/CentOS."
exit 1
fi

if [[ "${platform}" == *"Ubuntu"* && "$(echo ${os_version} | sed 's/\([0-9]\)\([0-9]\).*/\1\2/')" -lt "18" ]]; then
echo "This script requires Ubuntu 18 or greater."
exit 1
fi

if [[ "${platform}" == *"CentOS"* && "${os_version}" -lt "7" ]]; then
echo "This script requires CentOS 7 or greater."
exit 1
fi

echo "$(date '+%Y-%m-%d %H:%M:%S') preparing environment on '${platform}' '${os_version}'"
}

function check_dependencies_version() {
# python
if ! hash python3; then
echo "Python3 is not installed"
exit 1
fi
ver=$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/')
if [ "$ver" -lt "36" ]; then
echo "GraphScope requires python 3.6 or greater."
exit 1
fi
}

function install_dependencies() {
echo "$(date '+%Y-%m-%d %H:%M:%S') install dependencies."
if [[ "${platform}" == *"Ubuntu"* ]]; then
Expand All @@ -35,11 +103,10 @@ function install_dependencies() {
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo yum clean all
else
echo "Only support Ubuntu and CentOS"
exit 1
fi

check_dependencies_version

pip3 install -U pip --user
pip3 install graphscope vineyard wheel --user

Expand Down Expand Up @@ -125,6 +192,10 @@ then
exit 0
fi

get_os_version

check_os_compatibility

install_dependencies

start_docker
Expand Down

0 comments on commit 6865c1b

Please sign in to comment.