Migrate the PyPI package to use project name: khoj (#853)

### Changes
- Deprecate [khoj-assistant](https://pypi.org/project/khoj-assistant) pypi package. Use more accurate and succinct pypi project name, [khoj](https://pypi.org/project/khoj)
- Update references to use `khoj` pypi package in docs and code
- 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 [Django 5.0.7](https://pypi.org/project/Django/5.0.7/) which needs python >=3.10

### Verify
- Updated `pypi.yml` github workflow publishes to both (new) [khoj](https://pypi.org/project/khoj/1.16.1.dev16/), (old) [khoj-assistant](https://pypi.org/project/khoj-assistant/1.16.1.dev16/) pypi projects
- Can install Khoj python package with `pip install khoj`
This commit is contained in:
Debanjum 2024-07-17 01:05:51 -07:00 committed by GitHub
commit 2ab8fb78b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 38 additions and 36 deletions

View file

@ -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

View file

@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM ubuntu:jammy
LABEL org.opencontainers.image.source https://github.com/khoj-ai/khoj
LABEL "homepage" "https://khoj.dev"
LABEL "repository" "https://github.com/khoj-ai/khoj"
LABEL "org.opencontainers.image.source" "https://github.com/khoj-ai/khoj"
# Install System Dependencies
RUN apt update -y && apt -y install python3-pip swig curl

View file

@ -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)
</div>

View file

@ -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:

View file

@ -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

View file

@ -105,10 +105,10 @@ Run the following command in your terminal to install the Khoj server.
<TabItem value="macos" label="MacOS">
```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
```
</TabItem>
<TabItem value="win" label="Windows">
@ -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
```
</TabItem>
<TabItem value="unix" label="Linux">
```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
```
</TabItem>
</Tabs>
@ -257,7 +257,7 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
<Tabs groupId="environment">
<TabItem value="localsetup" label="Local Setup">
```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*
</TabItem>
@ -285,7 +285,7 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
<TabItem value="localsetup" label="Local Setup">
```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

View file

@ -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",

View file

@ -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 ()

View file

@ -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

View file

@ -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")
):

View file

@ -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)

View file

@ -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"),
}