From 9499bb6a05e1169a26d5d94baeadb0de696d9d6b Mon Sep 17 00:00:00 2001 From: "S. Andrew Sheppard" Date: Tue, 13 Jun 2023 12:33:37 -0400 Subject: [PATCH] replace setup.py with pyproject.toml --- .github/workflows/test.yml | 17 +-- .gitignore | 1 - pyproject.toml | 55 +++++++++ runserver.sh | 2 - setup.py | 105 ------------------ __init__.py => wq/db/__init__.py | 0 {rest => wq/db/rest}/__init__.py | 0 {rest => wq/db/rest}/apps.py | 0 {rest => wq/db/rest}/auth/__init__.py | 0 {rest => wq/db/rest}/auth/apps.py | 0 {rest => wq/db/rest}/auth/rest.py | 0 {rest => wq/db/rest}/auth/serializers.py | 0 {rest => wq/db/rest}/auth/views.py | 0 {rest => wq/db/rest}/exceptions.py | 0 {rest => wq/db/rest}/filters.py | 0 {rest => wq/db/rest}/management/__init__.py | 0 .../db/rest}/management/commands/__init__.py | 0 .../rest}/management/commands/dump_config.py | 0 {rest => wq/db/rest}/models.py | 0 {rest => wq/db/rest}/negotiation.py | 0 {rest => wq/db/rest}/pagination.py | 0 {rest => wq/db/rest}/permissions.py | 0 {rest => wq/db/rest}/renderers.py | 0 {rest => wq/db/rest}/routers.py | 0 {rest => wq/db/rest}/serializers.py | 0 {rest => wq/db/rest}/views.py | 0 26 files changed, 65 insertions(+), 115 deletions(-) create mode 100644 pyproject.toml delete mode 100755 runserver.sh delete mode 100644 setup.py rename __init__.py => wq/db/__init__.py (100%) rename {rest => wq/db/rest}/__init__.py (100%) rename {rest => wq/db/rest}/apps.py (100%) rename {rest => wq/db/rest}/auth/__init__.py (100%) rename {rest => wq/db/rest}/auth/apps.py (100%) rename {rest => wq/db/rest}/auth/rest.py (100%) rename {rest => wq/db/rest}/auth/serializers.py (100%) rename {rest => wq/db/rest}/auth/views.py (100%) rename {rest => wq/db/rest}/exceptions.py (100%) rename {rest => wq/db/rest}/filters.py (100%) rename {rest => wq/db/rest}/management/__init__.py (100%) rename {rest => wq/db/rest}/management/commands/__init__.py (100%) rename {rest => wq/db/rest}/management/commands/dump_config.py (100%) rename {rest => wq/db/rest}/models.py (100%) rename {rest => wq/db/rest}/negotiation.py (100%) rename {rest => wq/db/rest}/pagination.py (100%) rename {rest => wq/db/rest}/permissions.py (100%) rename {rest => wq/db/rest}/renderers.py (100%) rename {rest => wq/db/rest}/routers.py (100%) rename {rest => wq/db/rest}/serializers.py (100%) rename {rest => wq/db/rest}/views.py (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7b714e7..f81397dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: matrix: variant: [default, spatialite, postgis] python-version: ["3.11"] - django-version: [3.2.16, 4.1.3] + django-version: [3.2.19, 4.2.2] drf-version: [3.14.0] include: - python-version: "3.11" @@ -20,19 +20,19 @@ jobs: drf-version: 3.12.4 variant: default - python-version: "3.11" - django-version: 4.1.3 + django-version: 4.2.2 drf-version: 3.14.0 variant: nonroot - python-version: 3.9 - django-version: 4.1.3 + django-version: 4.2.2 drf-version: 3.14.0 variant: default - python-version: 3.8 - django-version: 4.1.3 + django-version: 4.2.2 drf-version: 3.14.0 variant: default - python-version: 3.7 - django-version: 3.2.16 + django-version: 3.2.19 drf-version: 3.14.0 variant: default steps: @@ -44,11 +44,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install build python -m pip install flake8 pytest wheel python -m pip install django==${{ matrix.django-version }} python -m pip install djangorestframework==${{ matrix.drf-version }} + python -m pip install html-json-forms drf-writable-nested pystache python -m pip install git+https://github.com/wq/django-natural-keys.git - python -m pip install . - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -74,4 +75,6 @@ jobs: psql wqdb_test -c "CREATE EXTENSION postgis;" python -m pip install "psycopg2-binary" - name: Test with unittest - run: python setup.py test + run: python -m unittest discover -s tests -t . -v + - name: Test build + run: python -m build diff --git a/.gitignore b/.gitignore index 7848e3c8..1aaeb134 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ *.sw? build dist -wq/ tests/media wqdb_test.sqlite3 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e9a654e2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] + +[project] +name = "wq.db" +dynamic = ["version"] +authors = [ + {name = "S. Andrew Sheppard", email = "andrew@wq.io"}, +] +description = "Django REST API for offline mobile surveys and field data collection." +readme = "README.md" +requires-python = ">=3.7" +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", + "Topic :: Software Development :: Libraries :: Application Frameworks", + "Topic :: Text Processing :: Markup :: HTML", + "Topic :: Scientific/Engineering :: GIS", + "Topic :: Database :: Database Engines/Servers", +] +dependencies = [ + "Django>=1.11,<5.0", + "djangorestframework>=3.8.0,<4.0", + "html-json-forms", + "natural-keys>=1.6.0", + "drf-writable-nested", + "pystache", +] + +[project.entry-points.wq] +"wq.db" = "wq.db" + +[project.urls] +Homepage = "https://wq.io/wq.db/" +Documentation = "https://wq.io/" +Source = "https://github.com/wq/wq.db" +"Release Notes" = "https://github.com/wq/wq.db/releases" +Issues = "https://github.com/wq/wq.db/issues" +CI = "https://github.com/wq/wq.db/actions/workflows/test.yml" + +[tool.setuptools_scm] diff --git a/runserver.sh b/runserver.sh deleted file mode 100755 index 974ba1b6..00000000 --- a/runserver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -python3 -m django runserver --settings=tests.settings diff --git a/setup.py b/setup.py deleted file mode 100644 index 158faffe..00000000 --- a/setup.py +++ /dev/null @@ -1,105 +0,0 @@ -import os -import sys -from setuptools import setup, find_packages - -LONG_DESCRIPTION = """ -Django REST API for offline mobile surveys and field data collection. -""" - - -def readme(): - # Attempt to load markdown file - try: - readme = open("README.md") - except IOError: - return LONG_DESCRIPTION - return readme.read() - - -def create_wq_namespace(): - """ - Generate the wq namespace package - (not checked in, as it technically is the parent of this folder) - """ - if os.path.isdir("wq"): - return - os.makedirs("wq") - init = open(os.path.join("wq", "__init__.py"), "w") - init.write("__import__('pkg_resources').declare_namespace(__name__)") - init.close() - - -def find_wq_packages(submodule): - """ - Add submodule prefix to found packages, since the packages within each wq - submodule exist at the top level of their respective repositories. - """ - packages = ["wq", submodule] - package_dir = {submodule: "."} - for package in find_packages(): - if package.split(".")[0] in ("wq", "tests"): - continue - full_name = submodule + "." + package - packages.append(full_name) - package_dir[full_name] = package.replace(".", os.sep) - - return packages, package_dir - - -create_wq_namespace() -packages, package_dir = find_wq_packages("wq.db") - -setup( - name="wq.db", - use_scm_version=True, - author="S. Andrew Sheppard", - author_email="andrew@wq.io", - url="https://wq.io/wq.db", - license="MIT", - packages=packages, - package_dir=package_dir, - namespace_packages=["wq"], - entry_points={"wq": "wq.db=wq.db"}, - description=LONG_DESCRIPTION.strip(), - long_description=readme(), - long_description_content_type="text/markdown", - install_requires=[ - "Django>=1.11,<5.0", - "djangorestframework>=3.8.0,<4.0", - "html-json-forms", - "natural-keys>=1.6.0", - "drf-writable-nested", - "pystache", - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", - "Framework :: Django :: 4.1", - "Topic :: Software Development :: Libraries :: Application Frameworks", - "Topic :: Text Processing :: Markup :: HTML", - "Topic :: Scientific/Engineering :: GIS", - "Topic :: Database :: Database Engines/Servers", - ], - test_suite="tests", - setup_requires=[ - "setuptools_scm", - ], - project_urls={ - "Homepage": "https://wq.io/wq.db/", - "Documentation": "https://wq.io/", - "Source": "https://github.com/wq/wq.db", - "Release Notes": "https://github.com/wq/wq.db/releases", - "Issues": "https://github.com/wq/wq.db/issues", - "CI": "https://github.com/wq/wq.db/actions/workflows/test.yml", - }, -) diff --git a/__init__.py b/wq/db/__init__.py similarity index 100% rename from __init__.py rename to wq/db/__init__.py diff --git a/rest/__init__.py b/wq/db/rest/__init__.py similarity index 100% rename from rest/__init__.py rename to wq/db/rest/__init__.py diff --git a/rest/apps.py b/wq/db/rest/apps.py similarity index 100% rename from rest/apps.py rename to wq/db/rest/apps.py diff --git a/rest/auth/__init__.py b/wq/db/rest/auth/__init__.py similarity index 100% rename from rest/auth/__init__.py rename to wq/db/rest/auth/__init__.py diff --git a/rest/auth/apps.py b/wq/db/rest/auth/apps.py similarity index 100% rename from rest/auth/apps.py rename to wq/db/rest/auth/apps.py diff --git a/rest/auth/rest.py b/wq/db/rest/auth/rest.py similarity index 100% rename from rest/auth/rest.py rename to wq/db/rest/auth/rest.py diff --git a/rest/auth/serializers.py b/wq/db/rest/auth/serializers.py similarity index 100% rename from rest/auth/serializers.py rename to wq/db/rest/auth/serializers.py diff --git a/rest/auth/views.py b/wq/db/rest/auth/views.py similarity index 100% rename from rest/auth/views.py rename to wq/db/rest/auth/views.py diff --git a/rest/exceptions.py b/wq/db/rest/exceptions.py similarity index 100% rename from rest/exceptions.py rename to wq/db/rest/exceptions.py diff --git a/rest/filters.py b/wq/db/rest/filters.py similarity index 100% rename from rest/filters.py rename to wq/db/rest/filters.py diff --git a/rest/management/__init__.py b/wq/db/rest/management/__init__.py similarity index 100% rename from rest/management/__init__.py rename to wq/db/rest/management/__init__.py diff --git a/rest/management/commands/__init__.py b/wq/db/rest/management/commands/__init__.py similarity index 100% rename from rest/management/commands/__init__.py rename to wq/db/rest/management/commands/__init__.py diff --git a/rest/management/commands/dump_config.py b/wq/db/rest/management/commands/dump_config.py similarity index 100% rename from rest/management/commands/dump_config.py rename to wq/db/rest/management/commands/dump_config.py diff --git a/rest/models.py b/wq/db/rest/models.py similarity index 100% rename from rest/models.py rename to wq/db/rest/models.py diff --git a/rest/negotiation.py b/wq/db/rest/negotiation.py similarity index 100% rename from rest/negotiation.py rename to wq/db/rest/negotiation.py diff --git a/rest/pagination.py b/wq/db/rest/pagination.py similarity index 100% rename from rest/pagination.py rename to wq/db/rest/pagination.py diff --git a/rest/permissions.py b/wq/db/rest/permissions.py similarity index 100% rename from rest/permissions.py rename to wq/db/rest/permissions.py diff --git a/rest/renderers.py b/wq/db/rest/renderers.py similarity index 100% rename from rest/renderers.py rename to wq/db/rest/renderers.py diff --git a/rest/routers.py b/wq/db/rest/routers.py similarity index 100% rename from rest/routers.py rename to wq/db/rest/routers.py diff --git a/rest/serializers.py b/wq/db/rest/serializers.py similarity index 100% rename from rest/serializers.py rename to wq/db/rest/serializers.py diff --git a/rest/views.py b/wq/db/rest/views.py similarity index 100% rename from rest/views.py rename to wq/db/rest/views.py