diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ace1071..99d6a547 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,18 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.4.0 + rev: v4.6.0 # pre-commit-hooks version hooks: - id: check-added-large-files - id: detect-private-key - id: trailing-whitespace - id: end-of-file-fixer + - id: check-merge-conflict + - id: detect-aws-credentials + args: [ --allow-missing-credentials ] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.2.0 # ruff version hooks: - id: ruff-format - id: ruff args: [ --fix, --exit-non-zero-on-fix ] +minimum_pre_commit_version: 3.7.1 diff --git a/Pipfile b/Pipfile index aa496334..1ee61cdb 100644 --- a/Pipfile +++ b/Pipfile @@ -26,7 +26,7 @@ pytest = "*" pytest-cov = "*" pytest-asyncio = "*" mock = "*" -pre-commit = "*" +pre-commit = ">=3.7.1" ruff = "==0.2.0" ipykernel = "*" jupyterlab = "*" diff --git a/docs/source/conf.py b/docs/source/conf.py index acb83a37..f6b11a97 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -70,9 +70,9 @@ autodoc_preserve_defaults = True # -- get version ------------------------------------------------------------- -from importlib.metadata import version +from metakb import __version__ -release = version = version("metakb") +release = version = __version__ # -- linkcode ---------------------------------------------------------------- def linkcode_resolve(domain, info): diff --git a/pyproject.toml b/pyproject.toml index 37f0da52..e26d7abb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ dynamic = ["version"] [project.optional-dependencies] tests = ["pytest", "pytest-cov", "mock", "pytest-asyncio"] -dev = ["pre-commit", "ruff==0.2.0"] +dev = ["pre-commit>=3.7.1", "ruff==0.2.0"] notebooks = ["ipykernel", "jupyterlab"] docs = [ "sphinx==6.1.3", @@ -68,11 +68,10 @@ Source = "https://github.com/cancervariants/metakb" metakb = "metakb.cli:cli" [build-system] -requires = ["setuptools>=64"] +requires = ["setuptools>=64", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" -[tool.setuptools.dynamic] -version = {attr = "metakb.version.__version__"} +[tool.setuptools_scm] [tool.setuptools.packages.find] where = ["src"] diff --git a/src/metakb/__init__.py b/src/metakb/__init__.py index 424223a4..5d0b478f 100644 --- a/src/metakb/__init__.py +++ b/src/metakb/__init__.py @@ -1,7 +1,16 @@ """The MetaKB package.""" +from importlib.metadata import PackageNotFoundError, version from pathlib import Path APP_ROOT = Path(__file__).resolve().parents[0] # default date format for all saved data files DATE_FMT = "%Y%m%d" + + +try: + __version__ = version("metakb") +except PackageNotFoundError: + __version__ = "unknown" +finally: + del version, PackageNotFoundError diff --git a/src/metakb/main.py b/src/metakb/main.py index cbaf2cba..fb5258ee 100644 --- a/src/metakb/main.py +++ b/src/metakb/main.py @@ -6,6 +6,7 @@ from fastapi import FastAPI, Query from fastapi.openapi.utils import get_openapi +from metakb import __version__ from metakb.log_handle import configure_logs from metakb.query import PaginationParamError, QueryHandler from metakb.schemas.api import ( @@ -15,7 +16,6 @@ SearchStudiesService, ServiceMeta, ) -from metakb.version import __version__ query = QueryHandler() diff --git a/src/metakb/schemas/api.py b/src/metakb/schemas/api.py index 37e9b4fc..60a92ce2 100644 --- a/src/metakb/schemas/api.py +++ b/src/metakb/schemas/api.py @@ -3,8 +3,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr +from metakb import __version__ from metakb.schemas.variation_statement import VariantTherapeuticResponseStudy -from metakb.version import __version__ class ServiceMeta(BaseModel): diff --git a/src/metakb/version.py b/src/metakb/version.py deleted file mode 100644 index 2871e7b5..00000000 --- a/src/metakb/version.py +++ /dev/null @@ -1,2 +0,0 @@ -"""MetaKB version""" -__version__ = "2.0.0-dev1"