From 0b6771b75bd4317bc5acc5b2da9c7886000fa9f5 Mon Sep 17 00:00:00 2001 From: "S. Andrew Sheppard" Date: Tue, 13 Jun 2023 16:47:13 -0400 Subject: [PATCH] replace setup.py with pyproject.toml --- .github/workflows/test.yml | 9 +- .gitmodules | 2 +- pyproject.toml | 60 ++++++++++++ set_dev_version.sh | 2 +- setup.py | 106 --------------------- __init__.py => wq/create/__init__.py | 0 django_project => wq/create/django_project | 0 forms.py => wq/create/forms.py | 0 projects.py => wq/create/projects.py | 0 version.py => wq/create/version.py | 0 10 files changed, 69 insertions(+), 110 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py rename __init__.py => wq/create/__init__.py (100%) rename django_project => wq/create/django_project (100%) rename forms.py => wq/create/forms.py (100%) rename projects.py => wq/create/projects.py (100%) rename version.py => wq/create/version.py (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fdbd1d8..bba2d34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: matrix: variant: [spatialite, postgis, npm] python-version: ["3.11"] - django-version: [4.1.3] + django-version: [4.2.2] drf-version: [3.14.0] steps: - uses: actions/checkout@v2 @@ -26,6 +26,7 @@ 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 }} @@ -33,7 +34,10 @@ jobs: python -m pip install wq.build==2.0.0a0 python -m pip install wq.app==2.0.0a0 python -m pip install wq.db==2.0.0a0 - python -m pip install . + - name: Test build + run: | + python -m build + python -m pip install dist/*.whl - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -111,6 +115,7 @@ jobs: - name: Publish to Github Packages if: ${{ github.event_name == 'push' }} run: | + python -m pip install setuptools_scm ./set_dev_version.sh cd packages/$PACKAGE echo "registry=https://npm.pkg.github.com/wq" > .npmrc diff --git a/.gitmodules b/.gitmodules index d4de2d3..2c6e360 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "django_project"] - path = django_project + path = wq/create/django_project url = https://github.com/wq/wq-django-template.git diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d3aa6df --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] + +[project] +name = "wq.create" +dynamic = ["version"] +authors = [ + {name = "S. Andrew Sheppard", email = "andrew@wq.io"}, +] +description = "Project scaffolding tools for creating a new application with the wq framework." +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 :: JavaScript", + "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", + "Topic :: Software Development :: Libraries :: Application Frameworks", + "Topic :: Software Development :: Code Generators", + "Topic :: Text Processing :: Markup :: HTML", + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Pre-processors", +] +dependencies = [ + "wq.build", + "psycopg2-binary", + "xlsconv>=1.2.0", +] + +[project.entry-points.wq] +"wq.create" = "wq.create" + +[project.urls] +Homepage = "https://wq.io/wq.create/" +Documentation = "https://wq.io/" +Source = "https://github.com/wq/wq.create" +"Release Notes" = "https://github.com/wq/wq.create/releases" +Issues = "https://github.com/wq/wq.create/issues" +CI = "https://github.com/wq/wq.create/actions/workflows/test.yml" + +[tool.setuptools.packages.find] +include = ["wq.create*"] +exclude = ["wq.create.django_project.*"] + +[tool.setuptools.package-data] +"wq.create.django_project" = [ "**/*", "**/.gitignore" ] + +[tool.setuptools_scm] diff --git a/set_dev_version.sh b/set_dev_version.sh index 19bbcfe..62953ea 100755 --- a/set_dev_version.sh +++ b/set_dev_version.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=`python3 setup.py --version | \ +VERSION=`python -m setuptools_scm | \ sed s/\.dev/-dev/ | \ sed s/+/./ | \ sed "s/\.d[0-9]\{8\}$//" | \ diff --git a/setup.py b/setup.py deleted file mode 100644 index 2a9c003..0000000 --- a/setup.py +++ /dev/null @@ -1,106 +0,0 @@ -import os -from setuptools import setup - -LONG_DESCRIPTION = """ -Project scaffolding tools for creating a new application with the wq framework. -""" - - -def readme(): - 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__)") - - -def list_package_data(root): - """ - Include project template as package data - """ - paths = [] - - for base, dirs, files in os.walk(root, topdown=True): - if "node_modules" in dirs: - dirs.remove("node_modules") - paths.extend( - [ - os.path.join(base, name) - for name in files - if name not in (".git", "package-lock.json") - ] - ) - - assert paths, "Missing template data!" - - return paths - - -create_wq_namespace() - -# Project template data -TEMPLATES = [ - "django_project", -] -TEMPLATE_DATA = [] -for folder in TEMPLATES: - TEMPLATE_DATA.extend(list_package_data(folder)) - -setup( - name="wq.create", - use_scm_version=True, - author="S. Andrew Sheppard", - author_email="andrew@wq.io", - url="https://wq.io/wq.create", - license="MIT", - description=LONG_DESCRIPTION.strip(), - long_description=readme(), - long_description_content_type="text/markdown", - entry_points={"wq": "wq.create=wq.create"}, - packages=["wq.create"], - package_dir={"wq.create": "."}, - namespace_packages=["wq"], - package_data={"wq.create": TEMPLATE_DATA}, - install_requires=[ - "wq.build", - "psycopg2-binary", - "xlsconv>=1.2.0", - ], - setup_requires=[ - "setuptools_scm", - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: JavaScript", - "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", - "Topic :: Software Development :: Libraries :: Application Frameworks", - "Topic :: Software Development :: Code Generators", - "Topic :: Text Processing :: Markup :: HTML", - "Topic :: Software Development :: Build Tools", - "Topic :: Software Development :: Pre-processors", - ], -) diff --git a/__init__.py b/wq/create/__init__.py similarity index 100% rename from __init__.py rename to wq/create/__init__.py diff --git a/django_project b/wq/create/django_project similarity index 100% rename from django_project rename to wq/create/django_project diff --git a/forms.py b/wq/create/forms.py similarity index 100% rename from forms.py rename to wq/create/forms.py diff --git a/projects.py b/wq/create/projects.py similarity index 100% rename from projects.py rename to wq/create/projects.py diff --git a/version.py b/wq/create/version.py similarity index 100% rename from version.py rename to wq/create/version.py