From 583fa3c18861c1d409dc18ce35dae8b64b5ee612 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 16 Jul 2024 21:45:41 +0530 Subject: [PATCH] Migrate the pypi package to khoj project name. Update references - Deprecate khoj-assistant pypi package. Use more accurate and succinct pypi project name, khoj - Update references to sye khoj pypi package in docs and code instead of the legacy khoj-assistant pypi package - Update pypi workflow to publish to both khoj, khoj-assistant for now - Update stale python 3.9 support mentioned in our pyproject. Can't support python 3.9 as depend on latest django which support >=3.10 --- .github/workflows/pypi.yml | 25 ++++++++++--------- README.md | 2 +- documentation/docs/advanced/authentication.md | 2 +- .../docs/contributing/development.mdx | 2 +- documentation/docs/get-started/setup.mdx | 22 ++++++++-------- pyproject.toml | 5 ++-- src/interface/emacs/khoj.el | 4 +-- src/khoj/main.py | 2 +- src/khoj/routers/auth.py | 2 +- src/khoj/utils/cli.py | 2 +- src/khoj/utils/helpers.py | 2 +- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 79fab443..de2c8f2d 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -27,7 +27,7 @@ jobs: permissions: id-token: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -36,16 +36,12 @@ jobs: with: python-version: '3.11' - - name: ⬇️ Install Application + - name: ⬇️ Install Server run: python -m pip install --upgrade pip && pip install --upgrade . - - name: Install the Next.js application + - name: ⬇️ Install Web Client run: | yarn install - working-directory: src/interface/web - - - name: Build & export static Next.js app to Django static assets - run: | yarn ciexport working-directory: src/interface/web @@ -56,7 +52,12 @@ jobs: export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) rm -rf dist - # Build PyPi Package + # Build PyPI Package: khoj + pipx run build + + # Build legacy PyPI Package: khoj-assistant + sed -i.bak '/^name = "khoj"$/s//name = "khoj-assistant"/' pyproject.toml + rm pyproject.toml.bak pipx run build - name: 🌡️ Validate Python Package @@ -66,11 +67,11 @@ jobs: pipx run twine check dist/* - name: ⏫ Upload Python Package Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: khoj-assistant - path: dist/*.whl + name: khoj + path: dist/khoj-*.whl - - name: 📦 Publish Python Package to PyPI + - name: 📦 Publish Python Packages to PyPI if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master' uses: pypa/gh-action-pypi-publish@v1.8.14 diff --git a/README.md b/README.md index c233e521..1187315e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![test](https://github.com/khoj-ai/khoj/actions/workflows/test.yml/badge.svg)](https://github.com/khoj-ai/khoj/actions/workflows/test.yml) [![dockerize](https://github.com/khoj-ai/khoj/actions/workflows/dockerize.yml/badge.svg)](https://github.com/khoj-ai/khoj/pkgs/container/khoj) -[![pypi](https://github.com/khoj-ai/khoj/actions/workflows/pypi.yml/badge.svg)](https://pypi.org/project/khoj-assistant/) +[![pypi](https://github.com/khoj-ai/khoj/actions/workflows/pypi.yml/badge.svg)](https://pypi.org/project/khoj/) ![Discord](https://img.shields.io/discord/1112065956647284756?style=plastic&label=discord) diff --git a/documentation/docs/advanced/authentication.md b/documentation/docs/advanced/authentication.md index 2741f578..456f0c0c 100644 --- a/documentation/docs/advanced/authentication.md +++ b/documentation/docs/advanced/authentication.md @@ -41,7 +41,7 @@ To set up your self-hosted Khoj with Google Auth, you need to create a project i To implement this, you'll need to: 1. You must use the `python` package or build from source, because you'll need to install additional packages for the google auth libraries (`prod`). The syntax to install the right packages is ``` - pip install khoj-assistant[prod] + pip install khoj[prod] ``` 2. [Create authorization credentials](https://developers.google.com/identity/sign-in/web/sign-in) for your application. 3. Open your [Google cloud console](https://console.developers.google.com/apis/credentials) and create a configuration like below for the relevant `OAuth 2.0 Client IDs` project: diff --git a/documentation/docs/contributing/development.mdx b/documentation/docs/contributing/development.mdx index d7ea3ed9..1fa73f10 100644 --- a/documentation/docs/contributing/development.mdx +++ b/documentation/docs/contributing/development.mdx @@ -229,7 +229,7 @@ The core code for the Obsidian plugin is under `src/interface/obsidian`. The fil 4. Open the `khoj` folder in the file explorer that opens. You'll see a file called `main.js` in this folder. To test your changes, replace this file with the `main.js` file that was generated by the development server in the previous section. ## Create Khoj Release (Only for Maintainers) -Follow the steps below to [release](https://github.com/debanjum/khoj/releases/) Khoj. This will create a stable release of Khoj on [Pypi](https://pypi.org/project/khoj-assistant/), [Melpa](https://stable.melpa.org/#%252Fkhoj) and [Obsidian](https://obsidian.md/plugins?id%253Dkhoj). It will also create desktop apps of Khoj and attach them to the latest release. +Follow the steps below to [release](https://github.com/debanjum/khoj/releases/) Khoj. This will create a stable release of Khoj on [Pypi](https://pypi.org/project/khoj/), [Melpa](https://stable.melpa.org/#%252Fkhoj) and [Obsidian](https://obsidian.md/plugins?id%253Dkhoj). It will also create desktop apps of Khoj and attach them to the latest release. 1. Create and tag release commit by running the bump_version script. The release commit sets version number in required metadata files. ```shell diff --git a/documentation/docs/get-started/setup.mdx b/documentation/docs/get-started/setup.mdx index 5f739d6f..bc954bde 100644 --- a/documentation/docs/get-started/setup.mdx +++ b/documentation/docs/get-started/setup.mdx @@ -105,10 +105,10 @@ Run the following command in your terminal to install the Khoj server. ```shell # ARM/M1+ Machines -MAKE_ARGS="-DLLAMA_METAL=on" python -m pip install khoj-assistant +MAKE_ARGS="-DLLAMA_METAL=on" python -m pip install khoj # Intel Machines -python -m pip install khoj-assistant +python -m pip install khoj ``` @@ -122,19 +122,19 @@ python -m pip install khoj-assistant $env:CMAKE_ARGS = "-DLLAMA_VULKAN=on" # 2. Install Khoj - py -m pip install khoj-assistant + py -m pip install khoj ``` ```shell # CPU - python -m pip install khoj-assistant + python -m pip install khoj # NVIDIA (CUDA) GPU - CMAKE_ARGS="DLLAMA_CUDA=on" FORCE_CMAKE=1 python -m pip install khoj-assistant + CMAKE_ARGS="DLLAMA_CUDA=on" FORCE_CMAKE=1 python -m pip install khoj # AMD (ROCm) GPU - CMAKE_ARGS="-DLLAMA_HIPBLAS=on" FORCE_CMAKE=1 python -m pip install khoj-assistant + CMAKE_ARGS="-DLLAMA_HIPBLAS=on" FORCE_CMAKE=1 python -m pip install khoj # VULCAN GPU - CMAKE_ARGS="-DLLAMA_VULKAN=on" FORCE_CMAKE=1 python -m pip install khoj-assistant + CMAKE_ARGS="-DLLAMA_VULKAN=on" FORCE_CMAKE=1 python -m pip install khoj ``` @@ -257,7 +257,7 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau ```shell - pip install --upgrade khoj-assistant + pip install --upgrade khoj ``` *Note: To upgrade to the latest pre-release version of the khoj server run below command* @@ -285,7 +285,7 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau ```shell # uninstall khoj server - pip uninstall khoj-assistant + pip uninstall khoj # delete khoj postgres db dropdb khoj -U postgres @@ -318,13 +318,13 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau 1. Install [pipx](https://pypa.github.io/pipx/#install-pipx) 2. Use `pipx` to install Khoj to avoid dependency conflicts with other python packages. ```shell - pipx install khoj-assistant + pipx install khoj ``` 3. Now start `khoj` using the standard steps described earlier #### Install fails while building Tokenizer dependency -- **Details**: `pip install khoj-assistant` fails while building the `tokenizers` dependency. Complains about Rust. +- **Details**: `pip install khoj` fails while building the `tokenizers` dependency. Complains about Rust. - **Fix**: Install Rust to build the tokenizers package. For example on Mac run: ```shell brew install rustup diff --git a/pyproject.toml b/pyproject.toml index 78cedf92..2669f5ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] -name = "khoj-assistant" +name = "khoj" description = "An AI copilot for your Second Brain" readme = "README.md" license = "AGPL-3.0-or-later" @@ -27,7 +27,6 @@ classifiers = [ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -110,7 +109,7 @@ prod = [ "resend == 1.0.1", ] dev = [ - "khoj-assistant[prod]", + "khoj[prod]", "pytest >= 7.1.2", "pytest-xdist[psutil]", "pytest-django == 4.5.2", diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index ca805815..f8120d63 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -283,9 +283,9 @@ Auto invokes setup steps on calling main entrypoint." (if (/= (apply #'call-process khoj-server-python-command nil t nil "-m" "pip" "install" "--upgrade" - '("khoj-assistant")) + '("khoj")) 0) - (message "khoj.el: Failed to install Khoj server. Please install it manually using pip install `khoj-assistant'.\n%s" (buffer-string)) + (message "khoj.el: Failed to install Khoj server. Please install it manually using pip install `khoj'.\n%s" (buffer-string)) (message "khoj.el: Installed and upgraded Khoj server version: %s" (khoj--server-get-version))))) (defun khoj--server-start () diff --git a/src/khoj/main.py b/src/khoj/main.py index 9180d9e3..0a492e91 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -206,7 +206,7 @@ def set_state(args): state.host = args.host state.port = args.port state.anonymous_mode = args.anonymous_mode - state.khoj_version = version("khoj-assistant") + state.khoj_version = version("khoj") state.chat_on_gpu = args.chat_on_gpu diff --git a/src/khoj/routers/auth.py b/src/khoj/routers/auth.py index e7d28301..56116d25 100644 --- a/src/khoj/routers/auth.py +++ b/src/khoj/routers/auth.py @@ -41,7 +41,7 @@ if not state.anonymous_mode: from google.auth.transport import requests as google_requests from google.oauth2 import id_token except ImportError: - missing_requirements += ["Install the Khoj production package with `pip install khoj-assistant[prod]`"] + missing_requirements += ["Install the Khoj production package with `pip install khoj[prod]`"] if not os.environ.get("RESEND_API_KEY") and ( not os.environ.get("GOOGLE_CLIENT_ID") or not os.environ.get("GOOGLE_CLIENT_SECRET") ): diff --git a/src/khoj/utils/cli.py b/src/khoj/utils/cli.py index efbb596e..dd3388d9 100644 --- a/src/khoj/utils/cli.py +++ b/src/khoj/utils/cli.py @@ -59,7 +59,7 @@ def cli(args=None): # Set default values for arguments args.chat_on_gpu = not args.disable_chat_on_gpu - args.version_no = version("khoj-assistant") + args.version_no = version("khoj") if args.version: # Show version of khoj installed and exit print(args.version_no) diff --git a/src/khoj/utils/helpers.py b/src/khoj/utils/helpers.py index a98b715c..9775e7ce 100644 --- a/src/khoj/utils/helpers.py +++ b/src/khoj/utils/helpers.py @@ -259,7 +259,7 @@ def log_telemetry( # Populate telemetry data to log request_body = { "telemetry_type": telemetry_type, - "server_version": version("khoj-assistant"), + "server_version": version("khoj"), "os": platform.system(), "timestamp": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), }