From 70ed1dcf05aa9cd7e3c03afd47625dc8a75ab556 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 25 Feb 2024 20:11:51 +0100 Subject: [PATCH] Modernize packaging with pyproject.toml and setuptool_scm. --- .gitignore | 2 + CHANGELOG.rst | 1 + check | 13 +++-- docs/source/contrib/release_procedure.rst | 2 +- pyproject.toml | 68 +++++++++++++++++++++++ scripts/lesana | 6 +- scripts/openlibrary2lesana | 6 +- scripts/tellico2lesana | 6 +- setup.cfg | 7 --- setup.py | 53 ------------------ 10 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 8534f9c..02706ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.pyc .coverage +lesana/_version.py + .*.sw? diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 19d0926..fca98f5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ Unreleased * Command line code has been split in the hazwaz library. * Code cleanup. +* Modernize packaging with pyproject.toml and setuptool_scm. 0.9.1 ===== diff --git a/check b/check index beb841c..1843ff7 100755 --- a/check +++ b/check @@ -10,6 +10,9 @@ then exit 0 fi +PYTHON="${PYTHON:-python3}" +COVERAGE="${COVERAGE:-python3-coverage}" + export PYTHONDEVMODE=1 SUBCMD=$1 @@ -17,16 +20,14 @@ shift 1 case $SUBCMD in "tests") - #nose2-3 $COVER_OPT --log-level=ERROR -B --log-capture $* - nosetests3 $* + $PYTHON -m unittest discover -s tests ;; "coverage") - #nose2-3 --with-coverage --coverage-report=term \ - # --log-level=ERROR -B --log-capture $* - nosetests3 --with-coverage --cover-erase --cover-package=lesana $* + $COVERAGE run --source=lesana -m unittest discover -s tests + $COVERAGE report -m ;; "qa") - flake8 --select=E,F,W,C90,E123 --ignore=W503 . + flake8 --select=E,F,W,C90,E123 --ignore=W503 lesana tests scripts isort --check-only --diff . if which doc8 then diff --git a/docs/source/contrib/release_procedure.rst b/docs/source/contrib/release_procedure.rst index 4399c47..396f2d2 100644 --- a/docs/source/contrib/release_procedure.rst +++ b/docs/source/contrib/release_procedure.rst @@ -9,7 +9,7 @@ * Generate the distribution files:: - $ python3 setup.py sdist bdist_wheel + $ python3 -m build * Upload :: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..13cb29b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "lesana" +authors = [ + {name = "Elena ``of Valhalla'' Grandi", email = "valhalla@trueelena.org"}, +] +description = "Manage collection inventories throught yaml files." +readme = "README.rst" +requires-python = ">= 3.8" +license = {text = "AGPLv3+"} +keywords = ["collection", "inventory"] +classifiers = [ + 'Development Status :: 3 - Alpha', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: End Users/Desktop', + 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', + 'Operating System :: POSIX', + "Programming Language :: Python :: 3", + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Utilities', + ] +dependencies = [ + "ruamel.yaml", + "jinja2", + "python-dateutil", + #"xapian >= 1.4", +] +dynamic = ["version"] + +[project.optional-dependencies] +cli = [ + "hazwaz", +] + +[project.scripts] +lesana = "scripts.lesana:main" +openlibrary2lesana = "scripts.openlibrary2lesana:main" +tellico2lesana = "scripts.tellico2lesana:main" + +[project.urls] +Homepage = "https://lesana.trueelena.org/" +Documentation = "https://lesana.trueelena.org/" +Repository = "https://git.sr.ht/~valhalla/lesana" +Source = "https://git.sr.ht/~valhalla/lesana" +Issues = "https://todo.sr.ht/~valhalla/lesana" +Tracker = "https://todo.sr.ht/~valhalla/lesana" +Changelog = "https://git.sr.ht/~valhalla/lesana/tree/master/item/CHANGELOG.rst" +"Mailing lists" = "https://sr.ht/~valhalla/lesana/lists" + +[tool.setuptools_scm] +version_file = "lesana/_version.py" + +[tool.mypy.overrides] +module = [ + "xapian", + "argcomplete", + "hazwaz", +] +ignore_missing_imports = true diff --git a/scripts/lesana b/scripts/lesana index 6d7e4c0..177ca9b 100755 --- a/scripts/lesana +++ b/scripts/lesana @@ -8,7 +8,8 @@ import hazwaz import lesana.command -if __name__ == "__main__": + +def main(): # setup logging for lesana cli logger = logging.getLogger('lesana') ch = logging.StreamHandler() @@ -18,3 +19,6 @@ if __name__ == "__main__": logger.setLevel(logging.INFO) lesana.command.Lesana().run() + +if __name__ == "__main__": + main() diff --git a/scripts/openlibrary2lesana b/scripts/openlibrary2lesana index 8394a3d..c3d38e3 100755 --- a/scripts/openlibrary2lesana +++ b/scripts/openlibrary2lesana @@ -101,5 +101,9 @@ class OL2L(lesana.command.Command): print(saved_entry) -if __name__ == '__main__': +def main(): OL2L().main() + + +if __name__ == '__main__': + main() diff --git a/scripts/tellico2lesana b/scripts/tellico2lesana index f432946..c4dfdde 100755 --- a/scripts/tellico2lesana +++ b/scripts/tellico2lesana @@ -129,5 +129,9 @@ class T2L: self.collection.update_cache() -if __name__ == '__main__': +def main(): T2L().main() + + +if __name__ == '__main__': + main() diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a34c5e6..0000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[mypy] - -[mypy-xapian.*] -ignore_missing_imports = True - -[mypy-argcomplete.*] -ignore_missing_imports = True diff --git a/setup.py b/setup.py index ec85f17..de1ff6a 100644 --- a/setup.py +++ b/setup.py @@ -1,57 +1,4 @@ from setuptools import find_packages, setup -try: - with open("README.rst", 'r') as fp: - long_description = fp.read() -except IOError: - print("Could not read README.rst, long_description will be empty.") - long_description = "" - setup( - name='lesana', - version='0.10.0dev', - packages=find_packages(), - scripts=['scripts/lesana'], - package_data={ - '': ['*.yaml', 'post-checkout'] - }, - test_suite='tests', - install_requires=[ - # 'xapian >= 1.4', - 'ruamel.yaml', - 'jinja2', - 'python-dateutil', - 'hazwaz', - ], - python_requires='>=3', - # Metadata - author="Elena ``of Valhalla'' Grandi", - author_email='valhalla@trueelena.org', - description='Manage collection inventories throught yaml files.', - long_description=long_description, - long_description_content_type='text/x-rst', - license='AGPLv3+', - keywords='collection inventory', - url='https://lesana.trueelena.org/', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: End Users/Desktop', - 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', # noqa: E501 - 'Operating System :: POSIX', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Utilities', - ], - project_urls={ - 'Source': 'https://git.sr.ht/~valhalla/lesana', - 'Documentation': 'https://lesana.trueelena.org/', - 'Tracker': 'https://todo.sr.ht/~valhalla/lesana', - 'Mailing lists': 'https://sr.ht/~valhalla/lesana/lists', - }, ) -- 2.45.2