From 44598139cfc54be8addf349a62b7aebeda0747d2 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Fri, 24 May 2024 21:28:01 +0200 Subject: [PATCH] replace setup.py with pyproject.toml (#94) ... switching from setuptools to hatchling along the way because the former didn't want to work. --- .github/workflows/python-publish.yml | 4 +-- mypy.ini | 16 --------- pyproject.toml | 52 ++++++++++++++++++++++++++++ setup.py | 50 -------------------------- 4 files changed, 54 insertions(+), 68 deletions(-) delete mode 100644 mypy.ini create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index fbf6534..1e9f1e1 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -23,10 +23,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build twine + pip install build twine hatchling - name: Extract version id: get-version - run: echo "::set-output name=VERSION::$(python setup.py --version)" + run: echo "::set-output name=VERSION::$(python -m hatchling version)" - name: Build package run: python -m build - name: Check package diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 7132412..0000000 --- a/mypy.ini +++ /dev/null @@ -1,16 +0,0 @@ -[mypy] -# strict mode -warn_unused_configs = True -disallow_any_generics = True -disallow_subclassing_any = True -disallow_untyped_calls = True -disallow_untyped_defs = True -disallow_incomplete_defs = True -check_untyped_defs = True -disallow_untyped_decorators = True -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -no_implicit_reexport = True -strict_equality = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c5712d9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "pdfannots" +dynamic = ["version"] +requires-python = ">=3.8" +dependencies = ["pdfminer.six >= 20220319"] +description = "Tool to extract and pretty-print PDF annotations for reviewing" +readme = "README.md" +license = {file = "LICENSE.txt"} +authors = [ + {name = "Andrew Baumann", email = "pdfannots.pypi.org@ab.id.au"}, +] +classifiers = [ + "Intended Audience :: Science/Research", + "Topic :: Text Processing", + "License :: OSI Approved :: MIT License", + "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", +] + +[project.scripts] +pdfannots = "pdfannots.cli:main" + +[project.urls] +Homepage = "https://github.com/0xabu/pdfannots" + +[tool.hatch.version] +path = "pdfannots/__init__.py" + +[tool.mypy] +# strict mode +warn_unused_configs = true +disallow_any_generics = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +no_implicit_reexport = true +strict_equality = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 72e125b..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -from setuptools import setup, find_packages # type:ignore -import pathlib - - -def get_version_from_file(filename: pathlib.Path) -> str: - with open(filename, 'r') as fh: - for line in fh.readlines(): - if line.startswith('__version__'): - delim = '"' if '"' in line else "'" - return line.split(delim)[1] - - raise RuntimeError("Unable to find version string in %s" % filename) - - -def main() -> None: - here = pathlib.Path(__file__).parent.resolve() - setup( - name='pdfannots', - version=get_version_from_file(here / 'pdfannots' / '__init__.py'), - description='Tool to extract and pretty-print PDF annotations for reviewing', - long_description=(here / 'README.md').read_text(), - long_description_content_type='text/markdown', - url='https://github.com/0xabu/pdfannots', - author='Andrew Baumann', - author_email='pdfannots.pypi.org@ab.id.au', - classifiers=[ - 'Intended Audience :: Science/Research', - 'Topic :: Text Processing', - 'License :: OSI Approved :: MIT License', - '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', - ], - packages=find_packages(include=['pdfannots', 'pdfannots.*']), - package_data={'pdfannots': ['py.typed']}, - entry_points={ - 'console_scripts': [ - 'pdfannots=pdfannots.cli:main', - ], - }, - python_requires='>=3.8', - install_requires=['pdfminer.six >= 20220319'], - ) - - -if __name__ == '__main__': - main()