diff --git a/PREREQUISITES.md b/PREREQUISITES.md new file mode 100644 index 0000000..1a92404 --- /dev/null +++ b/PREREQUISITES.md @@ -0,0 +1,202 @@ +# Prerequisites Installation Guide + +This guide provides detailed installation instructions for all prerequisites needed to run the OpenSearch SQL CLI. + +## Git Installation + +**Linux:** +```bash +# Ubuntu/Debian +sudo apt update +sudo apt install git + +# CentOS/RHEL +sudo yum install git + +# Fedora +sudo dnf install git + +# Arch Linux +sudo pacman -S git +``` + +**macOS:** +```bash +# Using Homebrew (recommended) +brew install git + +# Using Xcode Command Line Tools +xcode-select --install +``` + +**Verify Installation:** +```bash +git --version +``` + +## Python 3.12 Installation + +> **Note**: The SQL CLI only works with Python 3, as Python 2 is no longer maintained since 01/01/2020. + +**Linux (Ubuntu/Debian):** +```bash +sudo apt update +sudo add-apt-repository ppa:deadsnakes/ppa +sudo apt install python3.12 python3.12-pip +``` + +**Linux (Amazon Linux 2023):** +```bash +sudo dnf install python3.12 python3.12-pip + +# Set up alias to use python3.12 as default python3 +alias python3=python3.12 +# Make alias permanent +echo "alias python3=python3.12" >> ~/.bashrc +source ~/.bashrc +``` + +**Linux (Amazon Linux 2):** +```bash +# Using pyenv (recommended) +curl https://pyenv.run | bash +echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc +echo 'eval "$(pyenv init --path)"' >> ~/.bashrc +source ~/.bashrc +pyenv install 3.12.7 +pyenv global 3.12.7 +``` + +**macOS:** +```bash +# Using Homebrew (recommended) +brew install python@3.12 + +# Using pyenv +curl https://pyenv.run | bash +pyenv install 3.12.0 +pyenv global 3.12.0 +``` + + + +**Verify Installation:** +```bash +python3 --version # Should show Python 3.12.x +python --version # Should show Python 3.12.x +``` + +## pip Installation + +**Linux:** +```bash +# Ubuntu/Debian +sudo apt update +sudo apt install python3-pip + +# CentOS/RHEL +sudo yum install python3-pip + +# Fedora +sudo dnf install python3-pip + +# Arch Linux +sudo pacman -S python-pip +``` + +**macOS:** +```bash +# Using Homebrew (recommended) +brew install python +# pip comes bundled with Python from Homebrew + +# Using get-pip.py (if Python is already installed) +curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +python3 get-pip.py +``` + +**Verify pip Installation:** +```bash +pip3 --version +# or +python3 -m pip --version +``` + +## Java Installation + +> **Important**: Java version 21 or higher is required. Java 21 is recommended (especially for Amazon Linux), Java 24 is also supported. + +**Linux:** +```bash +# Using SDKMAN (recommended) +curl -s "https://get.sdkman.io" | bash +source "$HOME/.sdkman/bin/sdkman-init.sh" +sdk install java 24-open + +# Using package manager +# Ubuntu/Debian +sudo apt update +sudo apt install openjdk-24-jdk + +# CentOS/RHEL/Fedora +sudo dnf install java-24-openjdk-devel + +# Amazon Linux 2023 +sudo dnf update +sudo dnf install java-24-amazon-corretto-devel + +# Amazon Linux 2 (manual installation) +wget https://corretto.aws/downloads/latest/amazon-corretto-24-x64-linux-jdk.tar.gz +tar -xzf amazon-corretto-24-x64-linux-jdk.tar.gz +sudo mv amazon-corretto-24.* /opt/corretto-24 +sudo ln -sf /opt/corretto-24/bin/java /usr/bin/java +sudo ln -sf /opt/corretto-24/bin/javac /usr/bin/javac +``` + +**macOS:** +```bash +# Using Homebrew +brew install openjdk@24 + +# Using SDKMAN +curl -s "https://get.sdkman.io" | bash +source "$HOME/.sdkman/bin/sdkman-init.sh" +sdk install java 24-open +``` + +**Verify Installation:** +```bash +java -version +javac -version +``` + +**Set Java Environment Variables:** + +**macOS:** +```bash +export JAVA_HOME=$(/usr/libexec/java_home -v 21) +export PATH=$JAVA_HOME/bin:$PATH + +# Make permanent +echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.bashrc +echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc +source ~/.bashrc +``` + +**Linux:** +```bash +# Find your Java installation path +sudo find /usr -name "java" -type f 2>/dev/null | grep bin + +# Set JAVA_HOME (replace with your actual Java path) +export JAVA_HOME=/usr/lib/jvm/java-21-openjdk # or java-21-amazon-corretto.x86_64 +export PATH=$JAVA_HOME/bin:$PATH + +# Make permanent +echo 'export JAVA_HOME=/usr/lib/jvm/java-21-openjdk' >> ~/.bashrc +echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc +source ~/.bashrc +``` + + + diff --git a/README.md b/README.md index 273f58b..337da1c 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,6 @@ This CLI acts as a safe testing environment, allowing smooth transitions between [sql-cli-build-badge]: https://github.com/opensearch-project/sql-cli/actions/workflows/sql-cli-test-and-build-workflow.yml/badge.svg [sql-cli-build-link]: https://github.com/opensearch-project/sql-cli/actions/workflows/sql-cli-test-and-build-workflow.yml -## Requirements - -- **Python** version 3.12+ -- **Java** version 21 - ## Features - **Multi-line input** @@ -104,39 +99,91 @@ release branch: sql-cli-1.0 release tag: sql-cli-v1.0.0 ``` -## Install - -Launch your local OpenSearch instance and make sure you have the OpenSearch SQL plugin installed. - -To install the SQL CLI: - - -1. We suggest you install and activate a python3 virtual environment to avoid changing your local environment: - -``` - pip install virtualenv - virtualenv venv - cd venv - source ./bin/activate -``` - - -2. Install the CLI: - -> TODO: Right now, user can install `pip install -e .` at the root directory until the current version package being published. - - ``` - pip install opensearchsql - ``` - - The SQL CLI only works with Python 3, since Python 2 is no longer maintained since 01/01/2020. See https://pythonclock.org/ - +## Prerequisites + +### Essential Requirements: +- **Git** - Required for cloning the repository +- **Python 3.12+** - Required runtime environment +- **pip** - Required for installing Python dependencies +- **Java 21** - Required Java runtime (Java 21 recommended, Java 24 supported, Java 21 preferred for Amazon Linux) +- **OpenSearch cluster** with SQL plugin installed + +> **Note for Windows Users**: The SQL CLI does not work natively on Microsoft Windows. Windows users can use WSL (Windows Subsystem for Linux) to run the CLI. + +📋 **For detailed installation instructions for all prerequisites, see [PREREQUISITES.md](PREREQUISITES.md)** + +> ⚠️ **Important**: Before proceeding with the installation, ensure all prerequisites are installed. If you need help installing any of the required tools (Git, Python 3.12+, pip, Java 21), please follow the detailed instructions in [PREREQUISITES.md](PREREQUISITES.md). + +## Installation Steps + +1. **Clone the repository** + ```bash + git clone https://github.com/opensearch-project/sql-cli + cd sql-cli + ``` + +2. **Set up Python virtual environment** + ```bash + python3 -m venv venv + source ./venv/bin/activate + ``` + +3. **Install dependencies** + ```bash + pip install -e . + ``` + +4. **Verify Java installation** + ```bash + java --version + ``` + Expected output (Java 21 or higher): + ``` + openjdk 21.0.2 2024-01-16 + OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13) + OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13, mixed mode, sharing) + ``` + + +5. **Set Java environment variables** (adjust version number based on your installed Java version) + + **macOS:** + ```bash + export JAVA_HOME=$(/usr/libexec/java_home -v 21) # Use -v 24 for Java 24 + export PATH=$JAVA_HOME/bin:$PATH + ``` + + **Linux:** + ```bash + # Find Java installation + sudo find /usr -name "java" -type f 2>/dev/null | grep bin + + # Set JAVA_HOME (replace with your Java installation path) + export JAVA_HOME=/usr/lib/jvm/java-21-amazon-corretto.x86_64 + export PATH=$JAVA_HOME/bin:$PATH + + # Make permanent + echo 'export JAVA_HOME=/usr/lib/jvm/java-21-amazon-corretto.x86_64' >> ~/.bashrc + echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc + source ~/.bashrc + + # Switch Java versions (if multiple versions installed) + sudo alternatives --config java + ``` + +6. **Launch the CLI** + + > **Connection Note**: By default, the CLI connects to `http://localhost:9200`. If you have OpenSearch running locally, you can launch directly. To connect to a remote cluster, use the `-e` flag with your cluster endpoint. + + ```bash + # Connect to local OpenSearch cluster (default) + opensearchsql + + # Connect to remote cluster + opensearchsql -e https://your-cluster-endpoint + ``` -3. To launch the CLI, run: - ``` - opensearchsql - ``` ## Startup Commands diff --git a/development_guide.md b/development_guide.md index 1109340..e78cd0c 100644 --- a/development_guide.md +++ b/development_guide.md @@ -9,14 +9,13 @@ This guide provides comprehensive information for developers who want to contrib - [Style](#style) - [Release Guide](#release-guide) -### Development Environment Set Up -- `pip install virtualenv` -- `virtualenv venv` to create virtual environment for **Python 3** -- `source ./venv/bin/activate` activate virtual env. -- `cd` into project root folder. -- `pip install --editable .` will install all dependencies from `setup.py`. - -### Code Architecture Details +## Development Environment Setup + +For complete setup instructions including prerequisites and installation steps, see the main [README.md](README.md#prerequisites) file. + +Once you have the environment set up, you can proceed with the development-specific information below. + +## Code Architecture Details #### Layered Architecture