From 4256030b4f9617c1b0ac1000b70f2872d5aabe3f Mon Sep 17 00:00:00 2001 From: ian_Cin Date: Wed, 29 Nov 2023 14:58:35 +0700 Subject: [PATCH] Adopt pyproject.toml (#89) * ditching setup.py in favour of pyproject.toml; bump to 0.3.2 * bump to 0.3.3 --- .github/workflows/unit-test.yaml | 5 ++- knowledgehub/__init__.py | 2 - pyproject.toml | 71 +++++++++++++++++++++++++++++ setup.py | 76 -------------------------------- 4 files changed, 75 insertions(+), 79 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 8882828..a965366 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -53,8 +53,11 @@ jobs: - name: Get cache key id: get-cache-key + # using tomli so that it works on windows. From python 3.11, this can be switched to the + # built-in tomllib run: | - package_version=$(python setup.py --version) + pip install tomli + package_version=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])") cache_key="${{ runner.os }}-py${{ matrix.python-version }}-v${package_version}" echo "key=$cache_key" | tee -a ${{ matrix.GITHUB_OUTPUT }} diff --git a/knowledgehub/__init__.py b/knowledgehub/__init__.py index 48255eb..c3ff9f6 100644 --- a/knowledgehub/__init__.py +++ b/knowledgehub/__init__.py @@ -21,5 +21,3 @@ try: haystack.telemetry.telemetry = None except ImportError: pass - -__version__ = "0.3.2" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..300af24 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +# build backand and build dependencies +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = false +packages.find.include = ["kotaemon*"] +packages.find.exclude = ["tests*", "env*"] + +# metadata and dependencies +[project] +name = "kotaemon" +version = "0.3.3" +requires-python = ">= 3.10" +description = "Kotaemon core library for AI development." +dependencies = [ + "langchain", + "theflow", + "llama-index>=0.9.0", + "llama-hub", + "gradio", + "openpyxl", + "cookiecutter", + "click", + "pandas", +] +readme = "README.md" +license = { text = "MIT License" } +authors = [ + { name = "john", email = "john@cinnamon.is" }, + { name = "ian", email = "ian@cinnamon.is" }, + { name = "tadashi", email = "tadashi@cinnamon.is" }, +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.optional-dependencies] +dev = [ + "ipython", + "pytest", + "pre-commit", + "black", + "flake8", + "sphinx", + "coverage", + "openai", + "chromadb", + "wikipedia", + "duckduckgo-search", + "googlesearch-python", + "python-dotenv", + "pytest-mock", + "unstructured[pdf]", + "farm-haystack==1.19.0", + "sentence_transformers", + "cohere", + "elasticsearch", + "pypdf", +] + +[project.scripts] +kh = "kotaemon.cli:main" + +[project.urls] +Homepage = "https://github.com/Cinnamon/kotaemon/" +Repository = "https://github.com/Cinnamon/kotaemon/" +Documentation = "https://github.com/Cinnamon/kotaemon/wiki" diff --git a/setup.py b/setup.py deleted file mode 100644 index 4e9e7de..0000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -import codecs -import re -from pathlib import Path - -import setuptools - - -def read(file_path: str) -> str: - return codecs.open(file_path, "r").read() - - -def get_version() -> str: - version_file = read(str(Path("kotaemon", "__init__.py"))) - match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - if match: - return match.group(1) - raise RuntimeError("Cannot find verison string") - - -setuptools.setup( - name="kotaemon", - version=get_version(), - author="john", - author_email="john@cinnamon.com", - description="Kotaemon core library for AI development", - long_description=read("README.md"), - long_description_content_type="text/markdown", - url="https://github.com/Cinnamon/kotaemon/", - packages=setuptools.find_packages( - exclude=("tests", "tests.*", "examples", "examples.*") - ), - install_requires=[ - "langchain", - "theflow", - "llama-index>=0.9.0", - "llama-hub", - "gradio", - "openpyxl", - "cookiecutter", - "click", - "pandas", - ], - extras_require={ - "dev": [ - "ipython", - "pytest", - "pre-commit", - "black", - "flake8", - "sphinx", - "coverage", - # optional dependency needed for test - "openai", - "chromadb", - "wikipedia", - "duckduckgo-search", - "googlesearch-python", - "python-dotenv", - "pytest-mock", - "unstructured[pdf]", - "farm-haystack==1.19.0", - "sentence_transformers", - "cohere", - "elasticsearch", - "pypdf", - ], - }, - entry_points={"console_scripts": ["kh=kotaemon.cli:main"]}, - python_requires=">=3.10", - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - include_package_data=True, -)