From 07948c708b4ea6153a5651e1f73567dd49f09df6 Mon Sep 17 00:00:00 2001 From: Julian Edwards Date: Mon, 22 Jul 2024 10:21:04 +1000 Subject: [PATCH] Use Hatch instead of Tox - Removes the old setup.[py,cfg] in favour of a modern pyproject.toml - Remove Tox in favour of Hatch --- .github/workflows/tests.yml | 8 ++-- .gitignore | 4 +- .vscode/settings.json | 19 +++++---- ChangeLog | 6 +++ README.rst | 4 +- RELEASING.txt | 17 ++++---- pyproject.toml | 80 +++++++++++++++++++++++++++++++++++++ requirements.txt | 6 --- setup.cfg | 33 --------------- setup.py | 11 ----- test-requirements.txt | 9 ----- tox.ini | 31 -------------- 12 files changed, 114 insertions(+), 114 deletions(-) delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 test-requirements.txt delete mode 100644 tox.ini diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1efdd53..cc698e0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.8, 3.9, 3.10, 3.11, 3.12] steps: - uses: actions/checkout@v3 @@ -22,9 +22,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox + pip install hatch - - name: Run Tox + - name: Run tests run: | - tox + hatch run ci diff --git a/.gitignore b/.gitignore index ea8e650..12581dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.tox/ +.hatch/ db_testtools.egg-info/ __pycache__/ *.pyc +dbtesttools/_version.py +dist/ diff --git a/.vscode/settings.json b/.vscode/settings.json index cfd93cf..e38c4ff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,28 @@ { - "python.pythonPath": "${workspaceFolder}/.tox/py3/bin/python3", - "python.formatting.provider": "black", - "python.formatting.blackArgs": [ + "[python]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + } + }, + "black-formatter.args": [ "--line-length", "79" ], - "python.linting.flake8Enabled": true, - "python.linting.enabled": true, "python.testing.pytestEnabled": false, - "python.testing.nosetestsEnabled": false, "python.testing.unittestEnabled": true, "files.watcherExclude": { "**/.coverage/**": true, "**/.eggs": true, "**/.stestr/**": true, "**/.testrepository/**": true, - "**/.tox/**": true + "${workspaceFolder}/build/**": true, + "**/.hatch/**": true }, "git.allowForcePush": true, "editor.wordWrapColumn": 79, "vim.textwidth": 79, + "githubPullRequests.defaultMergeMethod": "rebase" } + diff --git a/ChangeLog b/ChangeLog index 9ae4d07..2be4842 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ CHANGES ======= +2024.07.21 +---------- +* Use Hatch to test and build the project +* Replace Black with Ruff for formatting and checking +* Allow overriding of the PG server IP address + 2023.01.27 ---------- diff --git a/README.rst b/README.rst index 01666ed..c5825cf 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ after each test completes. Requirements ------------ -Python 3.7 and beyond should work. +Python 3.8 and beyond should work. Quickstart ---------- @@ -101,5 +101,5 @@ stable. Copyright --------- -db-testtools is copyright (c) 2021-2023 Cisco Systems, Inc. and its affiliates +db-testtools is copyright (c) 2021-2024 Cisco Systems, Inc. and its affiliates All rights reserved. diff --git a/RELEASING.txt b/RELEASING.txt index 3740414..64621fd 100644 --- a/RELEASING.txt +++ b/RELEASING.txt @@ -3,14 +3,11 @@ To release a new version of db-testtools: 1. Tag the current revision with the required release number, e.g. `git tag 2021.09.29` 2. Build the package: - `tox -e build-python-package` - 3. This will generate a new ChangeLog file. It needs to be committed as - a new revision. - 4. After committing, move the tag: `git tag -f 2021.09.29` - 5. Build the package again because PBR. - 6. Upload the package to testpyi first to make sure it is ok: - `tox -e testpypi dist/*2021.9.29*` - 7. If that looks ok, upload to the real pypi: - `tox -e pypi dist/*2021.9.29*` - 8. Push the new tag to Github: + `hatch build` + 3. Upload the package to testpyi first to make sure it is ok: + `hatch run testpypi dist/*2021.9.29*` + 4. If that looks ok, upload to the real pypi: + `hatch run pypi dist/*2021.9.29*` + 5. Push the new tag to Github: `git push origin 2021.09.29` + 6. Make a Github release diff --git a/pyproject.toml b/pyproject.toml index b5dfd97..998c552 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,83 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "db-testtools" +dynamic = ["version"] +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.8" +authors = [ + { name = "Julian Edwards", email = "juledwar@cisco.com" }, +] +maintainers = [ + { name = "Julian Edwards", email = "juledwar@cisco.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Framework :: Hatch", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "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 :: Utilities", +] +urls.Source = "https://github.com/juledwar/db-testtools" + +dependencies = [ + "docker>=5.0.2", + "fixtures>=3.0.0", + "psycopg2-binary>=2.9.1", + "retry>=0.9.2", + "sqlalchemy>=1.4.23", + "testresources>=2.0.1", +] +[project.optional-dependencies] +test = [ + "build>=0.7.0", + "coverage[toml]>=6.0.2", + "ipython>=7.28.0", + "pdbpp>=0.10.3", + "ruff>=0.5.3", + "stestr>=3.2.1", + "testscenarios>=0.5.0", + "testtools>=2.5.0", + "twine>=3.4.2", + +] + +[tool.hatch.version] +source = "vcs" +[tool.hatch.build.hooks.vcs] +version-file = "dbtesttools/_version.py" +[tool.hatch.build.targets.sdist] +include = ["/dbtesttools"] +exclude = ["tests"] + +[tool.hatch.envs.default] +path = ".hatch" +features = ["test"] + +scripts.formatcheck = [ + "ruff format --check dbtesttools", + "ruff check --select I --show-fixes dbtesttools" +] +scripts.format = [ + "ruff check --select I --fix-only --show-fixes dbtesttools", + "ruff format dbtesttools", +] +scripts.ci = ["formatcheck"] +scripts.testpypi = ["twine upload --repository testpypi {args}"] +scripts.pypi = ["twine upload --repository pypi {args}"] + [tool.coverage.run] omit = [ '*dbtesttools/tests*', diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index df27dd3..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -docker>=5.0.2 -fixtures>=3.0.0 -psycopg2-binary>=2.9.1 -retry>=0.9.2 -sqlalchemy>=1.4.23 -testresources>=2.0.1 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4b39bbe..0000000 --- a/setup.cfg +++ /dev/null @@ -1,33 +0,0 @@ -[metadata] -name = db-testtools -url = https://github.com/juledwar/db-testtools -long_description = file: README.rst -long_description_content_type = text/x-rst -license = Apache2.0 -python_requires = >=3.7 -maintainer = Julian Edwards -maintainer_email = juledwar@cisco.com -classifier = - Development Status :: 5 - Production/Stable - Environment :: Console - Intended Audience :: Developers - Intended Audience :: Information Technology - Natural Language :: English - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Topic :: Utilities - -[files] -packages = dbtesttools -exclude = - dbtesttools.testing - dbtesttools.tests - -[bdist_wheel] -universal = 1 - -[pbr] -skip_git_sdist = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 87a862b..0000000 --- a/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -import setuptools - -setuptools_version = tuple(map(int, setuptools.__version__.split(".", 2)[:2])) -if setuptools_version < (34, 4): - raise RuntimeError("setuptools 34.4 or newer is required, detected ", - setuptools_version) - -if __name__ == "__main__": - setuptools.setup( - setup_requires=["pbr>=2.0.0"], - pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 309f346..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -build>=0.7.0 -coverage[toml]==6.0.2 -ipython==7.28.0 -pdbpp==0.10.3 -ruff>=0.5.3 -stestr==3.2.1 -testscenarios==0.5.0 -testtools==2.5.0 -twine>=3.4.2 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index c34386d..0000000 --- a/tox.ini +++ /dev/null @@ -1,31 +0,0 @@ -[tox] -envlist = pep8, formatcheck - -[testenv] -passenv = - BASEPYTHON - PYTHONBREAKPOINT -basepython = python3 -envdir ={toxworkdir}/py3 -usedevelop = True -setenv = - VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -commands = - repl: ipython {posargs} - pep8: ruff check dbtesttools {posargs} - build-python-package: python -m build {posargs} - pypi: python -m twine upload {posargs} - testpypi: python -m twine upload --repository testpypi {posargs} - -[testenv:formatcheck] -commands = - ruff check --select I --show-fixes dbtesttools - ruff format --check dbtesttools - -[testenv:format] -commands = - ruff check --select I --fix-only --show-fixes dbtesttools - ruff format dbtesttools