diff --git a/.gitignore b/.gitignore
index c77cbfde..b47306de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -144,3 +144,6 @@ dmypy.json
# Pyre type checker
.pyre/
+
+# Generated by setuptools_scm, should be ignored by VCS
+gramps_webapi/_version.py
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e0fe431a..b942656d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,27 +1,27 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
- rev: v5.4.2
+ rev: v5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
- rev: 22.8.0
+ rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v0.782
+ rev: v1.11.2
hooks:
- id: mypy
args: [--ignore-missing-imports]
- repo: https://github.com/PyCQA/pylint
- rev: pylint-2.5.3
+ rev: v3.2.7
hooks:
- id: pylint
stages: [commit]
args:
- --score=n
- repo: https://github.com/PyCQA/pydocstyle
- rev: 5.0.2
+ rev: 6.3.0
hooks:
- id: pydocstyle
stages: [commit]
diff --git a/.pylintrc b/.pylintrc
index 640c0c57..7267541a 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -44,7 +44,6 @@ suggestion-mode=yes
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
-
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
@@ -60,87 +59,14 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
-disable=print-statement,
- parameter-unpacking,
- unpacking-in-except,
- old-raise-syntax,
- backtick,
- long-suffix,
- old-ne-operator,
- old-octal-literal,
- import-star-module-level,
- non-ascii-bytes-literal,
- raw-checker-failed,
+disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
- use-symbolic-message-instead,
- apply-builtin,
- basestring-builtin,
- buffer-builtin,
- cmp-builtin,
- coerce-builtin,
- execfile-builtin,
- file-builtin,
- long-builtin,
- raw_input-builtin,
- reduce-builtin,
- standarderror-builtin,
- unicode-builtin,
- xrange-builtin,
- coerce-method,
- delslice-method,
- getslice-method,
- setslice-method,
- no-absolute-import,
- old-division,
- dict-iter-method,
- dict-view-method,
- next-method-called,
- metaclass-assignment,
- indexing-exception,
- raising-string,
- reload-builtin,
- oct-method,
- hex-method,
- nonzero-method,
- cmp-method,
- input-builtin,
- round-builtin,
- intern-builtin,
- unichr-builtin,
- map-builtin-not-iterating,
- zip-builtin-not-iterating,
- range-builtin-not-iterating,
- filter-builtin-not-iterating,
- using-cmp-argument,
- eq-without-hash,
- div-method,
- idiv-method,
- rdiv-method,
- exception-message-attribute,
- invalid-str-codec,
- sys-max-int,
- bad-python3-import,
- deprecated-string-function,
- deprecated-str-translate-call,
- deprecated-itertools-function,
- deprecated-types-field,
- next-method-defined,
- dict-items-not-iterating,
- dict-keys-not-iterating,
- dict-values-not-iterating,
- deprecated-operator-function,
- deprecated-urllib-function,
- xreadlines-attribute,
- deprecated-sys-function,
- exception-escape,
- comprehension-escape,
- bad-whitespace,
- bad-continuation
+ use-symbolic-message-instead
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
@@ -588,5 +514,5 @@ valid-metaclass-classmethod-first-arg=cls
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
-overgeneral-exceptions=BaseException,
- Exception
+overgeneral-exceptions=builtins.BaseException,
+ builtins.Exception
diff --git a/gramps_webapi/_version.py b/gramps_webapi/_version.py
deleted file mode 100644
index c290e0db..00000000
--- a/gramps_webapi/_version.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Gramps Web API - A RESTful API for the Gramps genealogy program
-#
-# Copyright (C) 2020 David Straub
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-
-# make sure to match this version with the one in apispec.yaml
-__version__ = "2.4.2"
diff --git a/gramps_webapi/data/apispec.yaml b/gramps_webapi/data/apispec.yaml
index f2e3f742..348da570 100644
--- a/gramps_webapi/data/apispec.yaml
+++ b/gramps_webapi/data/apispec.yaml
@@ -8,7 +8,6 @@ info:
* More about Gramps and the numerous features it provides for genealogists can be found at https://gramps-project.org
- version: "2.4.2" # make sure to match this version with the one in _version.py
license:
name: "GNU Affero General Public License v3.0"
url: "http://www.gnu.org/licenses/agpl-3.0.html"
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..597128df
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,64 @@
+[project]
+name = "gramps-webapi"
+description = "A RESTful web API for the Gramps genealogical database."
+authors = [
+ { name = "Gramps Development Team" },
+ { name = "David M. Straub", email = "straub@protonmail.com" }
+]
+license = { text = "AGPL-3.0-or-later" }
+readme = "README.md"
+dynamic = ["version"]
+keywords = ["RESTful", "web API", "genealogy", "Gramps"]
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
+ "Operating System :: OS Independent",
+]
+requires-python = ">=3.8"
+dependencies = [
+ "gramps-desktop[GUI,i18n]==5.2.*",
+ "Click>=7.0",
+ "Flask>=2.1.0",
+ "Flask-Caching>=2.0.0",
+ "Flask-Compress",
+ "Flask-Cors",
+ "Flask-JWT-Extended>=4.2.1,!=4.4.0,!=4.4.1",
+ "Flask-Limiter>=2.9.0",
+ "Flask-SQLAlchemy",
+ "marshmallow>=3.13.0",
+ "webargs",
+ "SQLAlchemy",
+ "pdf2image",
+ "Pillow",
+ "bleach[css]>=5.0.0",
+ "jsonschema",
+ "ffmpeg-python",
+ "boto3",
+ "alembic",
+ "celery[redis]",
+ "Unidecode",
+ "pytesseract",
+ "gramps-ql>=0.3.0",
+ "sifts>=0.8.3",
+]
+
+[project.urls]
+homepage = "https://github.com/gramps-project/gramps-web-api"
+repository = "https://github.com/gramps-project/gramps-web-api"
+
+
+[build-system]
+requires = ["setuptools>=64.0", "setuptools_scm[toml]>=6.2", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[tool.isort]
+profile = "black"
+
+[tool.setuptools_scm]
+# NOTE: Using a version file avoids some overhead
+#
+# This file is explicitly ignored by version control.
+write_to = "gramps_webapi/_version.py"
+
+[tool.setuptools.packages.find]
+include = ["gramps_webapi", "gramps_webapi.*"]
diff --git a/setup.py b/setup.py
index b6cf91ff..66037561 100644
--- a/setup.py
+++ b/setup.py
@@ -19,54 +19,6 @@
"""The setup script."""
-from setuptools import find_packages, setup
+from setuptools import setup # pylint: disable=E0401
-with open("README.md") as readme_file:
- README = readme_file.read()
-
-with open("gramps_webapi/_version.py") as version_file:
- exec(version_file.read())
-
-
-REQUIREMENTS = [
- "gramps-desktop[GUI,i18n]==5.2.*",
- "Click>=7.0",
- "Flask>=2.1.0",
- "Flask-Caching>=2.0.0",
- "Flask-Compress",
- "Flask-Cors",
- "Flask-JWT-Extended>=4.2.1, !=4.4.0, !=4.4.1",
- "Flask-Limiter>=2.9.0",
- "Flask-SQLAlchemy",
- "marshmallow>=3.13.0",
- "webargs",
- "SQLAlchemy",
- "pdf2image",
- "Pillow",
- "bleach[css]>=5.0.0",
- "jsonschema",
- "ffmpeg-python",
- "boto3",
- "alembic",
- "celery[redis]",
- "Unidecode",
- "pytesseract",
- "gramps-ql>=0.3.0",
- "sifts>=0.8.3",
-]
-
-setup(
- author="Gramps Development Team",
- url="https://github.com/gramps-project/web-api",
- python_requires=">=3.8",
- description="A RESTful web API for the Gramps genealogical database.",
- license="AGPL v3 or greater",
- install_requires=REQUIREMENTS,
- long_description=README,
- long_description_content_type="text/markdown",
- include_package_data=True,
- name="gramps-webapi",
- packages=find_packages(include=["gramps_webapi", "gramps_webapi.*"]),
- version=__version__,
- zip_safe=False,
-)
+setup()
diff --git a/tests/test_version.py b/tests/test_version.py
deleted file mode 100644
index af972087..00000000
--- a/tests/test_version.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Gramps Web API - A RESTful API for the Gramps genealogy program
-#
-# Copyright (C) 2021 David Straub
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-
-"""Test consistent version numbers."""
-
-import unittest
-
-import yaml
-from pkg_resources import resource_filename
-
-from gramps_webapi import __version__
-
-
-class TestVersion(unittest.TestCase):
- """Test the version specifiers are consistent."""
-
- def test_version(self):
- """Test version in setup and apispec are equal."""
- with open(
- resource_filename("gramps_webapi", "data/apispec.yaml")
- ) as file_handle:
- schema = yaml.safe_load(file_handle)
- self.assertEqual(__version__, schema["info"]["version"])