Use "build" to build packages; add a pyproject.toml file
authorKarl O. Pinc <kop@karlpinc.com>
Thu, 28 Mar 2024 16:53:26 +0000 (11:53 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Thu, 28 Mar 2024 16:53:26 +0000 (11:53 -0500)
Makefile_pgwui.mk
pyproject.toml [new file with mode: 0644]
setup.cfg [deleted file]
setup.py

index de0208d9690f650778c0dc8fd882e890ce95f005..522e1c73c96a0a68b9e8da86face50aec782ee75 100644 (file)
@@ -24,7 +24,7 @@
 # Common Makefile for PGWUI projects
 #
 
-# Variables to customize:
+# Variables from the including Makefile.
 # PGWUI_COMPONENT := pgwui_example
 
 
@@ -82,9 +82,9 @@ run_tests: devel/testenv
 
 ## dist                Create sdist Python package in ./dist
 .PHONY: dist
-dist:
+dist: devel/buildenv
        rm -rf dist
-       ${PYTHON_EXE} setup.py sdist
+       devel/buildenv/bin/python -m build
 
 
 # Expected targets
@@ -187,11 +187,20 @@ update_testenv: devel/testenv
 
 # Development related targets
 
-# Re-create development environment when setup.py changes
-devel: setup.py
+# Re-create development environment when build environment changes
+devel: setup.py pyproject.toml MANIFEST.in
        rm -rf devel ${TOX_STUFF}
        mkdir devel
 
+# virtualenv for package building
+devel/buildenv: devel
+       [ -d devel/buildenv ] \
+         || ( ${VIRTUALENV} devel/buildenv ; \
+              devel/buildenv/bin/pip install --upgrade pip ; \
+              devel/buildenv/bin/pip install --upgrade setuptools ; \
+              devel/buildenv/bin/pip install build ; \
+            )
+
 # virtualenv for development
 devel/testenv: devel
        [ -d devel/testenv ] \
@@ -199,7 +208,7 @@ devel/testenv: devel
               devel/testenv/bin/pip install --upgrade pip ; \
               devel/testenv/bin/pip install --upgrade setuptools ; \
               devel/testenv/bin/pip install tox ; \
-              devel/testenv/bin/pip install -e '.[testing]' ; \
+              devel/testenv/bin/pip install -e '.[test]' ; \
             )
 
 # virtualenv for pytest
@@ -212,12 +221,12 @@ devel/pytest: devel dist
             devel/pytest/bin/pip install dist/${PGWUI_COMPONENT}-*.tar.gz ; \
             devel/pytest/bin/pip install flake8 ; \
             devel/pytest/bin/pip install pytest-cov ; \
-            devel/pytest/bin/pip install -e '.[testing]' ; \
+            devel/pytest/bin/pip install -e '.[test]' ; \
           ) \
        else \
           ( devel/pytest/bin/pip uninstall -y ${PGWUI_COMPONENT} ; \
             devel/pytest/bin/pip install dist/${PGWUI_COMPONENT}-*.tar.gz ; \
-            devel/pytest/bin/pip install -e '.[testing]' ; \
+            devel/pytest/bin/pip install -e '.[test]' ; \
             ) ; \
        fi
 
@@ -229,12 +238,12 @@ devel/pudb: devel dist
            devel/pudb/bin/pip install --upgrade setuptools ; \
            devel/pudb/bin/pip install --upgrade wheel ; \
            devel/pudb/bin/pip install dist/${PGWUI_COMPONENT}-*.tar.gz ; \
-           devel/pudb/bin/pip install -e '.[testing]' ; \
+           devel/pudb/bin/pip install -e '.[test]' ; \
            devel/pudb/bin/pip install pudb ; \
          ) \
        else \
          ( devel/pudb/bin/pip uninstall -y ${PGWUI_COMPONENT} ; \
-           devel/pudb/bin/pip install -e '.[testing]' ; \
+           devel/pudb/bin/pip install -e '.[test]' ; \
            devel/pudb/bin/pip install dist/${PGWUI_COMPONENT}-*.tar.gz \
          ) ; \
        fi
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644 (file)
index 0000000..8eeccdc
--- /dev/null
@@ -0,0 +1,78 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+# Have setuptools find all our packages, and, since include-package-data
+# defaults to true, this also includes all the data files found in
+# MANIFEST.in
+[tool.setuptools.packages.find]
+where = ["src"]
+
+[project]
+name = "pgwui_common"
+# Versioning is major.minor.fixes.  Major releases change (after 1.0.0)
+# when backward incompatibility is introduced.  Minor releases introduce
+# new features.  Fix releases introduce fixes.
+dynamic = [
+    "version", "readme",
+    "dependencies",         # dynamic because version numbers are injected
+    "optional-dependencies" # dynamic because version numbers are injected
+]
+description = 'Shared files for PGWUI Postgres web interfaces.'
+requires-python = ">=3.7"
+
+# The license should be clear from the classifier, below
+# license = {file = "LICENSE.txt"}
+authors = [{name = 'Karl O. Pinc', email = 'kop@karlpinc.com'}]
+urls = {'Home Page' = 'http://pgwui_common.readthedocs.io/'}
+# What does your project relate to?
+keywords = [
+        'database front end',
+        'interface',
+        'Postgres',
+        'Postgres user interface',
+        'Postgres web interface',
+        'PostgreSQL',
+        'Postgres front end',
+        'user interface',
+        'web',
+        'web front end'
+]
+# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
+classifiers = [
+    # How mature is this project? Common values are
+    #   3 - Alpha
+    #   4 - Beta
+    #   5 - Production/Stable
+    'Development Status :: 3 - Alpha',
+
+    # Indicate who your project is intended for
+    'Environment :: Web Environment',
+    'Framework :: Pyramid',
+    'Intended Audience :: End Users/Desktop',
+    'Intended Audience :: Information Technology',
+    'Intended Audience :: Science/Research',
+    'Intended Audience :: System Administrators',
+    'Topic :: Database :: Front-Ends',
+    'Topic :: Internet :: WWW/HTTP',
+    'Topic :: Scientific/Engineering',
+    'Topic :: Utilities',
+
+    # Pick your license as you wish (should match "license" above)
+    """License :: OSI Approved \
+       :: GNU Affero General Public License v3 or later (AGPLv3+)""",
+
+    # Specify the Python versions you support here. In particular, ensure
+    # that you indicate whether you support Python 2, Python 3 or both.
+    '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'
+]
+
+# [project.scripts]
+# script-name = 'module.path:function'
+
+# No entry points, no pyramid component discovery
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644 (file)
index 24eff81..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-[bdist_wheel]
-# Work with both python 2 and 3.
-universal=1
index 98dc527e2f55f699287452fba67398bc5e88cd86..d48cad4a98c72dd7b0b6e889b8073f41d0b93379 100644 (file)
--- a/setup.py
+++ b/setup.py
-"""A setuptools based setup module.
+# Copyright (C) 2016, 2017, 2018, 2019, 2020, 2024 The Meme Factory, Inc.
+# http://www.karlpinc.com/
 
-Copied from:
-https://github.com/pypa/sampleproject
-It's license applies to this file.
-"""
-# Copyright (c) 2016 The Python Packaging Authority (PyPA)
+# This file is part of ${PGWUI_Common}.
 #
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
+# 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.
 #
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
+# 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.
 #
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@karlpinc.com>
+
+import codecs     # To use a consistent encoding
+import setuptools
+import os
 
+#
+# version
+#
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+# Get program version
+with codecs.open(
+    os.path.join(here, "src", "pgwui_common", "VERSION"),
+    encoding="utf-8",
+) as version_file:
+    version = version_file.read().strip()
 
-# Always prefer setuptools over distutils
-from setuptools import setup, find_packages
-# To use a consistent encoding
-from codecs import open
-from os import path
 
+#
+# readme
+#
 
 # Get the long description from the README file
 def filter_readme():
-    '''Return README content with copyright at top removed'''
+    """Return README content with copyright at top removed"""
     lines = []
     past_copyright = False
-    with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
+    with open(os.path.join(here, "README.rst"), encoding="utf-8") as f:
         for line in f:
             if past_copyright:
                 lines.append(line)
             else:
-                if line == '.. #End Of Copyright Marker#\n':
+                if line == ".. #End Of Copyright Marker#\n":
                     past_copyright = True
-    return ''.join(lines)
-
-
-here = path.abspath(path.dirname(__file__))
-
-# Get program version
-with open(path.join(here, 'src', 'pgwui_common', 'VERSION'),
-          encoding='utf-8') as version_file:
-    version = version_file.read().strip()
-
-# Get the long description from the README file
-long_description = filter_readme()
+    return "".join(lines)
 
-# Pyramid testing requirements
-tests_require = [
-    'pgwui_develop==' + version,
-    'WebTest >= 1.3.1',  # py3 compat
-    'pytest>=3.7.4',
-    'pytest-cov',
-]
 
-setup(
-    name='pgwui_common',
-
-    # Versioning is major.minor.fixes.  Major releases change (after 1.0.0)
-    # when backward incompatibility is introduced.  Minor releases introduce
-    # new features.  Fix releases introduce fixes.
-    version=version,
-
-    description='Shared files for PGWUI Postgres web interfaces.',
-    long_description=long_description,
-    long_description_content_type='text/x-rst',
-
-    # The project's main homepage.
-    url='http://pgwui_common.readthedocs.io/',
-
-    # Author details
-    author='Karl O. Pinc',
-    author_email='kop@karlpinc.com',
-
-    # Choose your license
-    license='AGPLv3+',
-
-    # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
-    classifiers=[
-        # How mature is this project? Common values are
-        #   3 - Alpha
-        #   4 - Beta
-        #   5 - Production/Stable
-        'Development Status :: 4 - Beta',
-
-        # Indicate who your project is intended for
-        'Environment :: Web Environment',
-        'Framework :: Pyramid',
-        'Intended Audience :: End Users/Desktop',
-        'Intended Audience :: Information Technology',
-        'Intended Audience :: Science/Research',
-        'Intended Audience :: System Administrators',
-        'Topic :: Database :: Front-Ends',
-        'Topic :: Internet :: WWW/HTTP',
-        'Topic :: Scientific/Engineering',
-        'Topic :: Utilities',
-
-        # Pick your license as you wish (should match "license" above)
-        ('License :: OSI Approved '
-         ':: GNU Affero General Public License v3 or later (AGPLv3+)'),
-
-        # Specify the Python versions you support here. In particular, ensure
-        # that you indicate whether you support Python 2, Python 3 or both.
-        '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',
-    ],
-
-    # What does your project relate to?
-    keywords=[
-        'database front end',
-        'interface',
-        'Postgres',
-        'Postgres user interface',
-        'Postgres web interface',
-        'PostgreSQL',
-        'Postgres front end',
-        'user interface',
-        'web',
-        'web front end',
-    ],
-
-    # You can just specify the packages manually here if your project is
-    # simple. Or you can use find_packages().
-    packages=find_packages('src'),
-    package_dir={'': 'src'},
-
-    # Run-time dependencies.
-    install_requires=[
-        'pgwui_core==' + version,
-        # for plugin.py's entrypoint processing.
-        'importlib_metadata > 3.6 ; python_version < "3.10"',
-        'pyramid',
-        'pyramid_beaker',
-        'pyramid_mako',
-        'attrs',
-    ],
-
-    # List additional groups of dependencies here (e.g. development
-    # dependencies). You can install these using the following syntax,
-    # for example:
-    # $ pip install -e .[testing]
-    extras_require={
-        'testing': tests_require,
-    },
-
-    # If there are data files included in your packages that need to be
-    # installed, specify them here.
-    package_data={
-        'pgwui_common': [
-            'static/*.css',
-            'templates/*.mak',
-            'VERSION',
-        ],
-    },
+#
+# dependencies (run-time)
+#
+install_requires = [
+    'pgwui_core==' + version,
+    # for plugin.py's entrypoint processing.
+    'importlib_metadata > 3.6 ; python_version < "3.10"',
+    'pyramid',
+    'pyramid_beaker',
+    'pyramid_mako',
+    'attrs',
+],
 
-    # To provide executable scripts, use entry points in preference to the
-    # "scripts" keyword. Entry points provide cross-platform support and allow
-    # pip to create the appropriate form of executable for the target platform.
-    #
-    # Do not register PGWUI_Common in entry_points as a PGWUI component.
-    # Its configuration is manually coded.
-    # entry_points={
-    #     'console_scripts': [
-    #         'sample=sample:main',
-    #     ],
-    # },
-)
+#
+# optional-dependencies
+#
+extras_require = {
+    "test": [
+        "pgwui_develop==" + version,
+        "WebTest >= 1.3.1",  # py3 compat
+        "pytest>=3.7.4",
+        "pytest-cov",
+    ]
+}
+
+
+if __name__ == '__main__':
+    setuptools.setup(
+        version=version,
+        long_description=filter_readme(),
+        long_description_content_type='text/x-rst',
+        install_requires=install_requires,
+        extras_require=extras_require
+    )