From d611a0b571a0d44d138eecd75f34c163197f29dc Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 22 Nov 2023 16:50:47 -0800 Subject: [PATCH] Hatch support and general build cleanups. (#1014) * Hatch support and general build cleanups. --- .github/workflows/codeql-analysis.yml | 3 +- .github/workflows/python-package.yml | 7 +- .gitignore | 1 + pylintrc => .pylintrc | 0 MANIFEST.in | 3 - Makefile | 78 ++++---------- doc/.gitignore | 1 - mypy.ini | 13 --- pyproject.toml | 147 +++++++++++++++----------- pytest.ini | 3 - setup.cfg | 63 ----------- setup.py | 48 --------- 12 files changed, 111 insertions(+), 256 deletions(-) rename pylintrc => .pylintrc (100%) delete mode 100644 MANIFEST.in delete mode 100644 doc/.gitignore delete mode 100644 mypy.ini delete mode 100644 pytest.ini delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 957bb842..97f07ae9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -59,8 +59,7 @@ jobs: run: | sudo apt install -y gnome-keyring python -m pip install --upgrade pip - python -m pip install poetry - poetry install -E dnssec -E doh -E idna -E trio + python -m pip install cryptography trio idna httpx h2 aioquic - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7cc53ee1..2c83afbf 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -48,14 +48,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install poetry - poetry install -E dnssec -E doh -E idna -E trio -E doq + python -m pip install cryptography trio idna httpx h2 aioquic mypy pytest pytest-cov - name: Typecheck run: | - poetry run python -m mypy --install-types --non-interactive --disallow-incomplete-defs dns + python -m mypy --install-types --non-interactive --disallow-incomplete-defs dns - name: Test with pytest run: | - poetry run pytest --cov=dns --cov-branch --cov-report=xml:coverage.xml + pytest --cov=dns --cov-branch --cov-report=xml:coverage.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/.gitignore b/.gitignore index 86ac2e50..f4399571 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ htmlcov coverage.xml .dir-locals.el .vscode/ +doc/_build \ No newline at end of file diff --git a/pylintrc b/.pylintrc similarity index 100% rename from pylintrc rename to .pylintrc diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 30d9d390..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include LICENSE ChangeLog README.md -recursive-include examples *.txt *.py -recursive-include tests *.txt *.py Makefile *.good example query *.pickle *.text *.generic diff --git a/Makefile b/Makefile index 94cd586a..1cc3019f 100644 --- a/Makefile +++ b/Makefile @@ -15,74 +15,42 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile,v 1.16 2004/03/19 00:17:27 halley Exp $ - -PYTHON=python - -all: - ${PYTHON} ./setup.py build - -install: - ${PYTHON} ./setup.py install +build: + python -m build clean: - ${PYTHON} ./setup.py clean --all - find . -name '*.pyc' -exec rm {} \; - find . -name '*.pyo' -exec rm {} \; - rm -f TAGS rm -rf htmlcov .coverage rm -rf .pytest_cache - -distclean: clean docclean - rm -rf build dist - rm -f MANIFEST - rm -rf dnspython.egg-info + rm -rf .ruff_cache + rm -rf .mypy_cache + rm -rf doc/_build + rm -rf dist + rm -rf build doc: cd doc; make html -docclean: - rm -rf doc/_build - -check: test - test: - cd tests; make test - -potest: - poetry run pytest - -potestlf: - poetry run pytest --lf - -potype: - poetry run python -m mypy --install-types --non-interactive --disallow-incomplete-defs dns + pytest -potypetests: - poetry run python -m mypy --check-untyped-defs examples tests - -polint: - poetry run pylint dns - -poflake: - poetry run flake8 dns +check: test -poruff: - poetry run ruff dns +type: + python -m mypy --install-types --non-interactive --disallow-incomplete-defs dns -pocov: - poetry run coverage run --branch -m pytest - poetry run coverage html --include 'dns/*' - poetry run coverage report --include 'dns/*' +lint: + pylint dns -oldpokit: - po run python setup.py sdist --formats=zip bdist_wheel +flake: + flake8 dns -pokit: - po build +ruff: + ruff dns -findjunk: - find dns -type f | egrep -v '.*\.py' | egrep -v 'py\.typed' +cov: + coverage --branch -m pytest + coverage html --include 'dns/*' + coverage report --include 'dns/*' -poblack: - poetry run black dns examples tests +black: + black dns examples tests diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index e35d8850..00000000 --- a/doc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_build diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 416a5ea6..00000000 --- a/mypy.ini +++ /dev/null @@ -1,13 +0,0 @@ -[mypy] - -[mypy-trio] -ignore_missing_imports = True - -[mypy-pythoncom] -ignore_missing_imports = True - -[mypy-wmi] -ignore_missing_imports = True - -[mypy-httpcore.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 77736fab..fb652f28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,81 +1,100 @@ -[tool.poetry] +[build-system] +requires = ["hatchling>=1.17.0"] +build-backend = "hatchling.build" + +[project] name = "dnspython" -version = "2.5.0" description = "DNS toolkit" -authors = ["Bob Halley "] -license = "ISC" -packages = [ - {include = "dns"} -] -include = [ - { path="LICENSE", format="sdist" }, - { path="README.md", format="sdist" }, - { path="examples/*.txt", format="sdist" }, - { path="examples/*.py", format="sdist" }, - { path="tests/*.txt", format="sdist" }, - { path="tests/*.py", format="sdist" }, - { path="tests/*.good", format="sdist" }, - { path="tests/example", format="sdist" }, - { path="tests/query", format="sdist" }, - { path="tests/*.pickle", format="sdist" }, - { path="tests/*.text", format="sdist" }, - { path="tests/*.generic", format="sdist" }, - { path="tests/tls/*.crt", format="sdist" }, - { path="tests/tls/*.pem", format="sdist" }, - { path="util/**", format="sdist" }, - { path="setup.cfg", format="sdist" }, -] -exclude = [ - "**/.DS_Store", - "**/__pycache__/**", +authors = [{ name = "Bob Halley", email = "halley@dnspython.org" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: ISC License (ISCL)", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python", + "Topic :: Internet :: Name Service (DNS)", + "Topic :: Software Development :: Libraries :: Python Modules", + "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", ] readme = "README.md" +requires-python = ">=3.8" +dependencies = [] +dynamic = ["version"] + +[project.optional-dependencies] +dev = [ + "black>=23.1.0", + "coverage>=7.0", + "flake8>=5.0.3", + "mypy>=1.0.1", + "pylint>=2.7", + "pytest>=6.2.5", + "pytest-cov>=3.0.0", + "sphinx>=7.0.0", + "twine>=4.0.0", + "wheel>=0.41.0", +] +dnssec = ["cryptography>=41"] +doh = ["httpcore>=0.17.3", "httpx>=0.25.1", "h2>=4.1.0"] +doq = ["aioquic>=0.9.20"] +idna = ["idna>=2.1"] +trio = ["trio>=0.14"] +wmi = ["wmi>=1.5.1"] + +[project.urls] homepage = "https://www.dnspython.org" repository = "https://github.com/rthalley/dnspython.git" documentation = "https://dnspython.readthedocs.io/en/stable/" +issues = "https://github.com/rthalley/dnspython/issues" -[tool.poetry.urls] -"Bug Tracker" = "https://github.com/rthalley/dnspython/issues" - -[tool.poetry.dependencies] -python = "^3.8" -httpx = {version=">=0.24.1", optional=true} -httpcore = {version=">=0.17.3", optional=true} -h2 = {version=">=4.1.0", optional=true} -idna = {version=">=2.1,<4.0", optional=true} -cryptography = {version=">=2.6", optional=true} -trio = {version=">=0.14,<0.24", optional=true} -wmi = {version="^1.5.1", optional=true} -aioquic = {version=">=0.9.20", optional=true} +[tool.hatch.build.targets.sdist] +include = [ + "/dns/*.py", + "/dns/**/*.py", + "/dns/py.typed", + "/examples/*.txt", + "/examples/*.py", + "/tests/*.txt", + "/tests/*.py", + "/tests/*.good", + "/tests/example", + "/tests/query", + "/tests/*.pickle", + "/tests/*.text", + "/tests/*.generic", + "/tests/tls/*.crt", + "/tests/tls/*.pem", + "/util/**", +] -[tool.poetry.dev-dependencies] -pytest = ">=5.4.1,<8" -pytest-cov = "^4.0.0" -flake8 = "^5.0.3" -sphinx = "^7.0.0" -coverage = "^7.0" -twine = "^4.0.0" -wheel = "^0.41.0" -pylint = ">=2.7,<4" -mypy = ">=1.0.1" -black = "^23.1.0" +[tool.hatch.build.targets.wheel] +include = ["dns/*.py", "dns/**/*.py", "dns/py.typed"] -[tool.poetry.extras] -doh = ['httpx', 'h2', 'httpcore'] -idna = ['idna'] -dnssec = ['cryptography'] -trio = ['trio'] -wmi = ['wmi'] -doq = ['aioquic'] +[tool.hatch.envs.default] +features = ["trio", "dnssec", "idna", "doh", "doq", "dev"] -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" - -[tool.setuptools_scm] +[tool.hatch.version] +source = "code" +path = "dns/version.py" +expression = "version" [tool.ruff] ignore = ['E741', 'F401'] [tool.isort] profile = "black" + +[[tool.mypy.overrides]] +module = "pythoncom" +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = "wmi" +ignore_missing_imports = true diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 5b9d772c..00000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -# pytest.ini -[pytest] -junit_family=xunit1 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d4740672..00000000 --- a/setup.cfg +++ /dev/null @@ -1,63 +0,0 @@ -[metadata] -name = dnspython -version = 2.5.0 -author = Bob Halley -author_email = halley@dnspython.org -license = ISC -license_file = LICENSE -description = DNS toolkit -url = https://www.dnspython.org -project_urls = - Bug Tracker = https://github.com/rthalley/dnspython/issues - Documentation = https://dnspython.readthedocs.io/en/stable/ - Source Code = https://github.com/rthalley/dnspython -long_description = dnspython is a DNS toolkit for Python. It supports almost all - record types. It can be used for queries, zone transfers, and dynamic - updates. It supports TSIG authenticated messages and EDNS0. - - dnspython provides both high and low level access to DNS. The high - level classes perform queries for data of a given name, type, and - class, and return an answer set. The low level classes allow - direct manipulation of DNS zones, messages, names, and records. -long_description_content_type = text/plain -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: System Administrators - License :: OSI Approved :: ISC License (ISCL) - Operating System :: POSIX - Operating System :: Microsoft :: Windows - Programming Language :: Python - Topic :: Internet :: Name Service (DNS) - Topic :: Software Development :: Libraries :: Python Modules - 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 -provides = dns - -[options] -packages = - dns - dns.dnssecalgs - dns.quic - dns.rdtypes - dns.rdtypes.IN - dns.rdtypes.ANY - dns.rdtypes.CH -python_requires = >=3.8 -test_suite = tests -setup_requires = setuptools>=44; setuptools_scm[toml]>=3.4.3 - -[options.extras_require] -DOH = httpx>=0.21.1; h2>=4.1.0 -IDNA = idna>=2.1 -DNSSEC = cryptography>=2.6 -trio = trio>=0.14.0 -wmi = wmi>=1.5.1 -DOQ = aioquic>=0.9.20 - -[options.package_data] -dns = py.typed diff --git a/setup.py b/setup.py deleted file mode 100755 index cbbbecb0..00000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license -# -# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose with or without fee is hereby granted, -# provided that the above copyright notice and this permission notice -# appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import sys - -from setuptools import setup - -try: - sys.argv.remove("--cython-compile") -except ValueError: - compile_cython = False -else: - compile_cython = True - from Cython.Build import cythonize - - ext_modules = cythonize( - [ - "dns/*.py", - "dns/dnssecalgs/*.py", - "dns/quic/*.py", - "dns/rdtypes/*.py", - "dns/rdtypes/*/*.py", - ], - language_level="3", - ) - -kwargs = { - "ext_modules": ext_modules if compile_cython else None, - "zip_safe": False if compile_cython else None, -} - -setup(**kwargs) -- 2.47.3