diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9147b23 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,51 @@ +name: Publish Python Package + +on: + release: + types: [created] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: setup.py + - name: Install dependencies + run: | + pip install '.[test]' + - name: Run tests + run: | + pytest + deploy: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: pip + cache-dependency-path: setup.py + - name: Install dependencies + run: | + pip install setuptools wheel twine build + - name: Publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python -m build + twine upload dist/* + diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml new file mode 100644 index 0000000..c1361ff --- /dev/null +++ b/.github/workflows/test-coverage.yml @@ -0,0 +1,47 @@ +name: Calculate Test Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e .[test] + python -m pip install pytest-cov + + - name: Run tests + run: |- + ls -lah + pytest --cov=tsellm --cov-report xml:coverage.xml --cov-report term + ls -lah + + - name: Upload coverage report + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: coverage.xml + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e6e596 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Test + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: setup.py + - name: Install dependencies + run: | + pip install '.[test]' + - name: Run tests + run: | + pytest + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f58447b --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.venv +__pycache__/ +*.py[cod] +*$py.class +venv +.eggs +.pytest_cache +*.egg-info +.DS_Store +dist +build +.idea/ diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..ebdc665 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,18 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.11" + +sphinx: + configuration: docs/conf.py + +formats: + - pdf + - epub + +python: + install: + - requirements: docs/requirements.txt + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3eeb18d --- /dev/null +++ b/LICENSE @@ -0,0 +1,32 @@ + + +BSD License + +Copyright (c) 2024, Florents Tselai +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c4b4f1 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +
+ +
+ +
+ +
+ LLM support in SQLite
+
+ Status |
+ Why |
+ How |
+ Installation |
+ Usage |
+ Roadmap
+
+
+ +
+ + + + + + +## Status + +## Why + +## How + + +## Installation + +## Usage + +```bash +pip install tsellm +``` + +### Development + +```bash +pip install -e '.[test]' +pytest +``` + diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..bfdc987 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,8 @@ +coverage: + status: + project: + default: + informational: true + patch: + default: + informational: true diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..6450ba0 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,23 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = tsellm +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +livehtml: + sphinx-autobuild -b html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(0) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..6edf683 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from subprocess import PIPE, Popen +from beanbag_docutils.sphinx.ext.github import github_linkcode_resolve + +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "myst_parser", + "sphinx_copybutton", + "sphinx.ext.autodoc", + "sphinx.ext.extlinks", + "sphinx_copybutton", + "sphinx.ext.linkcode", +] +myst_enable_extensions = ["colon_fence"] + + +def linkcode_resolve(domain, info): + return github_linkcode_resolve( + domain=domain, + info=info, + allowed_module_names=["tsellm"], + github_org_id="Florents-Tselai", + github_repo_id="tsellm", + branch="main", + ) + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = ".rst" + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "tsellm" +copyright = "2024, Florents Tselai" +author = "Florents Tselai" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +pipe = Popen("git describe --tags --always", stdout=PIPE, shell=True) +git_version = pipe.stdout.read().decode("utf8") + +if git_version: + version = git_version.rsplit("-", 1)[0] + release = git_version +else: + version = "" + release = "" + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = "en" + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# The name of the Pygments (syntax highlighting) style to use. +# pygments_style = "sphinx" + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "furo" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. + +html_theme_options = {} + +html_title = "tsellm" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# -- Options for HTMLHelp output ------------------------------------------ + +# Output file base name for HTML help builder. +htmlhelp_basename = "tsellm-doc" + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "tsellm.tex", + "tsellm documentation", + "Florents Tselai \n florents@tselai.com", + "manual", + ) +] + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "tsellm", + "tsellm documentation", + [author], + 1, + ) +] + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "tsellm", + "tsellm documentation", + author, + "tsellm", + "LLM support in SQLite", + ) +] diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..14c198e --- /dev/null +++ b/docs/index.md @@ -0,0 +1,22 @@ +# tsellm + +```{eval-rst} +.. note:: + This is note text. Use a note for information you want the user to + pay particular attention to. +``` + +```{eval-rst} +.. warning:: + This is warning text. Use a warning for information the user must understand to avoid negative consequences. +``` + + + + +```{toctree} +--- +maxdepth: 3 +--- + +``` diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..6d8f51e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,7 @@ +sphinx==7.2.6 +furo==2023.9.10 +sphinx-autobuild +sphinx-copybutton +myst-parser +cogapp +beanbag-docutils>=2.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1d19011 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +from setuptools import setup +import os + +VERSION = "0.0.0a0" + + +def get_long_description(): + with open( + os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"), + encoding="utf8", + ) as fp: + return fp.read() + + +setup( + name="tsellm", + description="LLM support in SQLite", + long_description=get_long_description(), + long_description_content_type="text/markdown", + author="Florents Tselai", + url="https://github.com/Florents-Tselai/tsellm", + entry_points=""" + [console_scripts] + tsellm=tsellm.cli:cli + """, + project_urls={ + "Issues": "https://github.com/Florents-Tselai/tsellm/issues", + "CI": "https://github.com/Florents-Tselai/tsellm/actions", + "Changelog": "https://github.com/Florents-Tselai/tsellm/releases", + }, + license="MIT License", + version=VERSION, + packages=["tsellm"], + install_requires=["click", "llm", "setuptools", "pip"], + extras_require={"test": ["pytest", "pytest-cov", "black", "ruff", "click"]}, + python_requires=">=3.7" +) diff --git a/tests/test_tsellm.py b/tests/test_tsellm.py new file mode 100644 index 0000000..73cb0a6 --- /dev/null +++ b/tests/test_tsellm.py @@ -0,0 +1,5 @@ +from tsellm import example_function + + +def test_example_function(): + assert example_function() == 2 diff --git a/tsellm/__init__.py b/tsellm/__init__.py new file mode 100644 index 0000000..923334e --- /dev/null +++ b/tsellm/__init__.py @@ -0,0 +1,2 @@ +def example_function(): + return 1 + 1 diff --git a/tsellm/__main__.py b/tsellm/__main__.py new file mode 100644 index 0000000..7e34ccd --- /dev/null +++ b/tsellm/__main__.py @@ -0,0 +1,4 @@ +from .cli import cli + +if __name__ == "__main__": + cli() \ No newline at end of file diff --git a/tsellm/cli.py b/tsellm/cli.py new file mode 100644 index 0000000..c8a5d15 --- /dev/null +++ b/tsellm/cli.py @@ -0,0 +1,15 @@ +import click +@click.group() +@click.version_option() +def cli(): + """ CLI for tsellm """ + pass + +@cli.command() +@click.argument( + "name", + type=str, + required=True, +) +def hello(name): + print(f"Hello, {name}") \ No newline at end of file