From 14048385fb3b84bac582bca57a660b8ae78f0f4a Mon Sep 17 00:00:00 2001 From: Tim Bradgate Date: Fri, 22 Mar 2024 00:55:34 +0000 Subject: [PATCH] Add hatch config for build --- .github/workflows/python-test.yml | 43 +++++++++++++++++ .gitignore | 6 ++- .idea/couch-potato.iml | 2 +- hatch.toml | 23 ++++++++++ pyproject.toml | 46 +++++++++++++++++++ .../couch_potato}/__init__.py | 0 {couch-potato => src/couch_potato}/_model.py | 6 +-- {couch-potato => src/couch_potato}/_types.py | 0 .../couch_potato}/couch_potato.py | 6 +-- {couch-potato => src/couch_potato}/errors.py | 0 {couch-potato => src/couch_potato}/fields.py | 2 +- {couch-potato => src/couch_potato}/model.py | 2 +- tests/test_dummy.py | 3 ++ 13 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/python-test.yml create mode 100644 hatch.toml rename {couch-potato => src/couch_potato}/__init__.py (100%) rename {couch-potato => src/couch_potato}/_model.py (95%) rename {couch-potato => src/couch_potato}/_types.py (100%) rename {couch-potato => src/couch_potato}/couch_potato.py (90%) rename {couch-potato => src/couch_potato}/errors.py (100%) rename {couch-potato => src/couch_potato}/fields.py (75%) rename {couch-potato => src/couch_potato}/model.py (98%) create mode 100644 tests/test_dummy.py diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..18b9202 --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,43 @@ +name: Python Unit Tests +on: [push, pull_request] + +concurrency: + group: test-${{ github.head_ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + run: + name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + 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 }} + - name: Install Hatch + run: pip install --upgrade hatch + - name: Run tests and track code coverage + run: hatch run cov + run-container-matrix: + name: Container matrix on Linux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install Hatch + run: pip install --upgrade hatch hatch-containers + - name: Run tests in container matrix + run: hatch run all:test diff --git a/.gitignore b/.gitignore index 7565408..250a3a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ # Repo specifc ignore +/src/couch_potato/_version.py +dist/ .python-version -couch-potato/__pycache__/ -tests/local_test.py +**/__pycache__/ +local_test.py # Generic ignore # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider diff --git a/.idea/couch-potato.iml b/.idea/couch-potato.iml index aa4d9e3..e5664a0 100644 --- a/.idea/couch-potato.iml +++ b/.idea/couch-potato.iml @@ -2,7 +2,7 @@ - + diff --git a/hatch.toml b/hatch.toml new file mode 100644 index 0000000..6a2e7b5 --- /dev/null +++ b/hatch.toml @@ -0,0 +1,23 @@ +[envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] + +[envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "- coverage combine", + "coverage report --show-missing", +] +cov = [ + "test-cov", + "cov-report", +] + +[envs.all] +type = "container" + +[[envs.all.matrix]] +python = ["3.7", "3.8", "3.9", "3.10", "3.11"] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e69de29..e3d7389 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["hatchling", "hatch-vcs", "hatch-requirements-txt"] +build-backend = "hatchling.build" + +[project] +name="couch_potato" +dynamic = ["version", "dependencies"] +readme = "README.md" +requires-python = ">=3.7" +license-files = { paths = ["LICENSE.md"] } +authors = [ + { name = "Tim Bradgate", email = "timbradgate@hotmail.co.uk" }, +] +keywords=["couchbase", "odm", "orm"] +classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Database", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules" +] + +[project.urls] +Documentation = "https://github.com/Tim020/couch-potato" +"Source code" = "https://github.com/Tim020/couch-potato" +Issues = "https://github.com/Tim020/couch-potato/issues" + +[tool.hatch.metadata.hooks.requirements_txt] +files = ["requirements.txt"] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/couch_potato/_version.py" + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.github", + "dist" +] diff --git a/couch-potato/__init__.py b/src/couch_potato/__init__.py similarity index 100% rename from couch-potato/__init__.py rename to src/couch_potato/__init__.py diff --git a/couch-potato/_model.py b/src/couch_potato/_model.py similarity index 95% rename from couch-potato/_model.py rename to src/couch_potato/_model.py index 0e0a846..790c406 100644 --- a/couch-potato/_model.py +++ b/src/couch_potato/_model.py @@ -1,10 +1,10 @@ from typing import TYPE_CHECKING, Dict -from _types import BucketBind, ScopeBind, Field -from model import BaseModel, KeyGenerator +from src.couch_potato._types import BucketBind, ScopeBind, Field +from src.couch_potato.model import BaseModel, KeyGenerator if TYPE_CHECKING: - from couch_potato import CouchPotato + from src.couch_potato.couch_potato import CouchPotato def make_meta_model(cp: "CouchPotato"): diff --git a/couch-potato/_types.py b/src/couch_potato/_types.py similarity index 100% rename from couch-potato/_types.py rename to src/couch_potato/_types.py diff --git a/couch-potato/couch_potato.py b/src/couch_potato/couch_potato.py similarity index 90% rename from couch-potato/couch_potato.py rename to src/couch_potato/couch_potato.py index b7044cf..54934dd 100644 --- a/couch-potato/couch_potato.py +++ b/src/couch_potato/couch_potato.py @@ -4,9 +4,9 @@ from couchbase.cluster import Cluster from couchbase.collection import Collection -from _types import BucketBind -from _model import make_meta_model -from model import BaseModel +from src.couch_potato._types import BucketBind +from src.couch_potato._model import make_meta_model +from src.couch_potato.model import BaseModel class CouchPotato: diff --git a/couch-potato/errors.py b/src/couch_potato/errors.py similarity index 100% rename from couch-potato/errors.py rename to src/couch_potato/errors.py diff --git a/couch-potato/fields.py b/src/couch_potato/fields.py similarity index 75% rename from couch-potato/fields.py rename to src/couch_potato/fields.py index 33ff386..ee7a0c8 100644 --- a/couch-potato/fields.py +++ b/src/couch_potato/fields.py @@ -1,4 +1,4 @@ -from _types import Field +from src.couch_potato._types import Field class Integer(Field): diff --git a/couch-potato/model.py b/src/couch_potato/model.py similarity index 98% rename from couch-potato/model.py rename to src/couch_potato/model.py index 88e1bd9..411ba0e 100644 --- a/couch-potato/model.py +++ b/src/couch_potato/model.py @@ -5,7 +5,7 @@ from couchbase.options import InsertOptions, ReplaceOptions from couchbase.scope import Scope -from errors import ModelAttributeError, FieldNotFound, ReadOnlyError +from src.couch_potato.errors import ModelAttributeError, FieldNotFound, ReadOnlyError T = TypeVar('T', bound='BaseModel') diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..9024935 --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,3 @@ +def test_dummy(): + print("Hello world") + assert True