From e305e660fede7b0d7dc7d9ebf422fbe992023ac3 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Sun, 3 Dec 2023 22:02:59 +0200 Subject: [PATCH 1/8] Add pyproject.toml --- .travis.yml | 72 ------------------------------------- appveyor-cache.txt | 1 - appveyor.yml | 43 ----------------------- cp33-tox-requirements.txt | 3 -- haas/__init__.py | 4 +-- pyproject.toml | 74 +++++++++++++++++++++++++++++++++++++++ test_requirements.txt | 2 -- tox-requirements.txt | 4 +-- 8 files changed, 77 insertions(+), 126 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor-cache.txt delete mode 100644 appveyor.yml delete mode 100644 cp33-tox-requirements.txt create mode 100644 pyproject.toml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6379953f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,72 +0,0 @@ -language: python - -env: - global: - PYTHONUNBUFFERED="1" - -matrix: - include: - - python: "2.7" - env: TOXENV="cp27" - - python: "3.4" - env: TOXENV="cp34" - - python: "3.5" - env: TOXENV="cp35" - - python: "3.6" - env: TOXENV="cp36" - - dist: xenial - python: "3.7" - env: TOXENV="cp37" - - python: "pypy" - env: TOXENV="pp2" - - python: "pypy3" - env: TOXENV="pp3" - - os: osx - language: shell - env: TOXPY27="/usr/local/bin/python2" TOXENV="cp27" - python: "2.7" - - os: osx - language: shell - env: TOXPY36="/usr/local/bin/python3" TOXENV="cp36" - python: "3.6" - - dist: xenial - python: "3.7" - env: TOXENV="flake8" - - allow_failures: - - os: osx - -cache: - directories: - - $HOME/.cache/pip - - $HOME/Library/Caches/Homebrew - -branches: - only: - - master - - /^maintenance\/.*$/ - - /^v\d+\.\d+\.\d+.*$/ - -addons: - homebrew: - packages: - - python@2 - - python@3 - -before_cache: - - brew cleanup - -install: pip install -q -rtox-requirements.txt -script: tox -v - -notifications: - email: - - travis-ci@simonjagoe.com - -after_success: - - | - if [[ "$TOXENV" != "flake8" ]]; then - if [[ "$TRAVIS_PYTHON_VERSION" == "2.6" ]]; then pip install "idna < 2.8"; fi - pip install coveralls - coveralls - fi diff --git a/appveyor-cache.txt b/appveyor-cache.txt deleted file mode 100644 index 573541ac..00000000 --- a/appveyor-cache.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4c5afc26..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -build: false -shallow_clone: true -skip_branch_with_pr: true -image: Visual Studio 2015 - -environment: - - pythonunbuffered: "1" - toxenv: "cp27,cp34,cp35,cp36,cp37" - - matrix: - - TOXPY27: "C:/Python27-x64/python.exe" - TOXPY34: "C:/Python34-x64/python.exe" - TOXPY35: "C:/Python35-x64/python.exe" - TOXPY36: "C:/Python36-x64/python.exe" - TOXPY37: "C:/Python37-x64/python.exe" - PREFIX: "C:/Python33-x64" - - TOXPY27: "C:/Python27/python.exe" - TOXPY34: "C:/Python34/python.exe" - TOXPY35: "C:/Python35/python.exe" - TOXPY36: "C:/Python36/python.exe" - TOXPY37: "C:/Python37/python.exe" - PREFIX: "C:/Python33" - -matrix: - fast_finish: true - -branches: - only: - - master - -cache: - - C:\Users\appveyor\AppData\Local\pip\Cache -> appveyor-cache.txt - -init: - - ps: $Env:path = $Env:PREFIX + ";" + $Env:PREFIX + "/Scripts;" + $Env:path -install: - - cmd: python -m pip install -rtox-requirements.txt -test_script: - - python -m tox -v -on_success: - - python -m pip install codecov - - python -m codecov diff --git a/cp33-tox-requirements.txt b/cp33-tox-requirements.txt deleted file mode 100644 index 8636dde6..00000000 --- a/cp33-tox-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pip < 11.0.0; python_version == '3.3' -wheel <= 0.29; python_version == '3.3' -setuptools < 40.0.0; python_version == '3.3' diff --git a/haas/__init__.py b/haas/__init__.py index 280b375d..9166c6b1 100644 --- a/haas/__init__.py +++ b/haas/__init__.py @@ -6,13 +6,13 @@ # of the 3-clause BSD license. See the LICENSE.txt file for details. from __future__ import absolute_import, unicode_literals +import logging + try: from haas._version import version as __version__ except ImportError: # pragma: no cover __version__ = 'notset' -import logging - class NullHandler(logging.Handler): # pragma: no cover def emit(self, record): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..4dde42d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,74 @@ +[project] +name = "haas" +dynamic = ["version"] +description = "Extensible Python Test Runner" +authors = [ + { name = "Simon Jagoe", email = "simon@scalative.com" }, +] +license = { file = "LICENSE.txt" } +readme = "README.rst" +requires-python = ">= 3.7" +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: Unix", + "Topic :: Software Development", + "Topic :: Software Development :: Testing", +] +dependencies = [ + "statistics", + "stevedore", +] + +[project.optional-dependencies] +test = [ + "coverage", + "testfixtures", +] +docs = [ + "refactordoc", + "sphinx", + "sphinx-rtd-theme", +] + +[project.urls] +Repository = "https://github.com/scalative/haas" + +[tool.setuptools] +packages = [ + "haas", + "haas.plugins", + "haas.tests", + "haas.plugins.tests", +] + +[project.scripts] +haas = "haas.main:main" + +[project.entry-points."haas.hooks.environment"] +coverage = "haas.plugins.coverage:Coverage" + +[project.entry-points."haas.discovery"] +default = "haas.plugins.discoverer:Discoverer" + +[project.entry-points."haas.runner"] +default = "haas.plugins.runner:BaseTestRunner" +parallel = "haas.plugins.parallel_runner:ParallelTestRunner" + +[project.entry-points."haas.result.handler"] +default = "haas.plugins.result_handler:StandardTestResultHandler" +quiet = "haas.plugins.result_handler:QuietTestResultHandler" +verbose = "haas.plugins.result_handler:VerboseTestResultHandler" +timing = "haas.plugins.result_handler:TimingResultHandler" + +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_file = "haas/_version.py" diff --git a/test_requirements.txt b/test_requirements.txt index ff0b4f14..1508653a 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,4 +1,2 @@ coverage -unittest2; python_version == '2.6' -mock; python_version < '3.3' testfixtures diff --git a/tox-requirements.txt b/tox-requirements.txt index c78bdc39..053148f8 100644 --- a/tox-requirements.txt +++ b/tox-requirements.txt @@ -1,3 +1 @@ -tox < 3.0.0; python_version == '3.3' -tox; python_version != '3.3' -virtualenv == 15.2.0; python_version == '3.3' +tox From 26e0b3413d633137e900a7cb7f7a335580d2ee42 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Sun, 3 Dec 2023 23:25:45 +0200 Subject: [PATCH 2/8] Update CI for new project format --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69e9d743..518f4fe1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,9 +28,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install run: | - pip install -e . - pip install -r "test_requirements.txt" - pip --version + pip install -e '.[test]' - name: Run tests with unittest run: | coverage run --branch -m unittest discover -v -t . haas From 003177e955ee97ef2cebca53507dab0feee2bf87 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Tue, 5 Dec 2023 22:12:50 +0200 Subject: [PATCH 3/8] Add flake8 config to .flake8 file --- .flake8 | 6 ++++++ setup.cfg | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .flake8 delete mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..686e2e45 --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +exclude = + .tox, + .git, + __pycache__, + docs/source/conf.py diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index af57bc0b..00000000 --- a/setup.cfg +++ /dev/null @@ -1 +0,0 @@ -[bdist_wheel] From 731c1ce9d61464a0d3397220bd979eda518ea28e Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Sun, 3 Dec 2023 23:22:16 +0200 Subject: [PATCH 4/8] Remove setup.py --- setup.py | 172 ------------------------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 4ab7600c..00000000 --- a/setup.py +++ /dev/null @@ -1,172 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2013-2014 Simon Jagoe -# All rights reserved. -# -# This software may be modified and distributed under the terms -# of the 3-clause BSD license. See the LICENSE.txt file for details. -import os -import subprocess - -from setuptools import setup - - -MAJOR = 0 -MINOR = 10 -MICRO = 0 - -IS_RELEASED = False - -VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) - - -# Return the git revision as a string -def git_version(): - def _minimal_ext_cmd(cmd): - # construct minimal environment - env = {} - for k in ['SYSTEMROOT', 'PATH']: - v = os.environ.get(k) - if v is not None: - env[k] = v - # LANGUAGE is used on win32 - env['LANGUAGE'] = 'C' - env['LANG'] = 'C' - env['LC_ALL'] = 'C' - out = subprocess.Popen( - cmd, stdout=subprocess.PIPE, env=env, - ).communicate()[0] - return out - - try: - out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) - git_revision = out.strip().decode('ascii') - except OSError: - git_revision = "Unknown" - - try: - out = _minimal_ext_cmd(['git', 'rev-list', '--count', 'HEAD']) - git_count = out.strip().decode('ascii') - except OSError: - git_count = '0' - - return git_revision, git_count - - -def write_version_py(filename='haas/_version.py'): - template = """\ -# -*- coding: utf-8 -*- -# Copyright (c) 2013-2014 Simon Jagoe -# All rights reserved. -# -# This software may be modified and distributed under the terms -# of the 3-clause BSD license. See the LICENSE.txt file for details. -from __future__ import absolute_import, unicode_literals - -# THIS FILE IS GENERATED FROM SETUP.PY -version = '{version}' -full_version = '{full_version}' -git_revision = '{git_revision}' -is_released = {is_released} - -if not is_released: - version = full_version -""" - fullversion = VERSION - if os.path.exists('.git'): - git_rev, dev_num = git_version() - elif os.path.exists('haas/_version.py'): - # must be a source distribution, use existing version file - try: - from haas._version import git_revision as git_rev - from haas._version import full_version as full_v - except ImportError: - raise ImportError("Unable to import git_revision. Try removing " - "haas/_version.py and the build " - "directory before building.") - import re - match = re.match(r'.*?\.dev(?P\d+)$', full_v) - if match is None: - dev_num = '0' - else: - dev_num = match.group('dev_num') - else: - git_rev = "Unknown" - dev_num = '0' - - if not IS_RELEASED: - fullversion += '.dev{0}'.format(dev_num) - - with open(filename, "wt") as fp: - fp.write(template.format(version=VERSION, - full_version=fullversion, - git_revision=git_rev, - is_released=IS_RELEASED)) - - -if __name__ == "__main__": - install_requires = [ - 'enum34', - 'statistics', - 'stevedore >= 3.5.2, < 5.0.0', - ] - - write_version_py() - from haas import __version__ - - with open('README.rst') as fh: - long_description = fh.read() - - setup( - name='haas', - version=__version__, - url='https://github.com/scalative/haas', - author='Simon Jagoe', - author_email='simon@scalative.com', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: MacOS', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: OS Independent', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3 :: Only', - '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', - 'Programming Language :: Python :: 3.12', - 'Topic :: Software Development', - 'Topic :: Software Development :: Testing', - ], - description='Extensible Python Test Runner', - long_description=long_description, - license='BSD', - packages=['haas', 'haas.plugins', 'haas.tests', 'haas.plugins.tests'], - install_requires=install_requires, - entry_points={ - 'console_scripts': [ - 'haas = haas.main:main', - ], - 'haas.hooks.environment': [ - 'coverage = haas.plugins.coverage:Coverage', - ], - 'haas.discovery': [ - 'default = haas.plugins.discoverer:Discoverer', - ], - 'haas.runner': [ - 'default = haas.plugins.runner:BaseTestRunner', - 'parallel = haas.plugins.parallel_runner:ParallelTestRunner', # noqa - ], - 'haas.result.handler': [ - 'default = haas.plugins.result_handler:StandardTestResultHandler', # noqa - 'quiet = haas.plugins.result_handler:QuietTestResultHandler', - 'verbose = haas.plugins.result_handler:VerboseTestResultHandler', # noqa - 'timing = haas.plugins.result_handler:TimingResultHandler', - ] - }, - ) From 060c7f08d347131a81a0158ad29bc15871866d94 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Tue, 5 Dec 2023 22:12:32 +0200 Subject: [PATCH 5/8] Remove old files --- build.sh | 8 -------- dev_requirements.txt | 6 ------ test_requirements.txt | 2 -- tox-requirements.txt | 1 - tox.ini | 46 ------------------------------------------- 5 files changed, 63 deletions(-) delete mode 100755 build.sh delete mode 100644 dev_requirements.txt delete mode 100644 test_requirements.txt delete mode 100644 tox-requirements.txt delete mode 100644 tox.ini diff --git a/build.sh b/build.sh deleted file mode 100755 index dadc5c11..00000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -ex -export SOURCE_DATE_EPOCH="$(date +%s)" -git clean -fxd -python setup.py sdist -rm -rf build/ -python setup.py bdist_wheel --python-tag py3 -rm -rf build/ diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index 26766b33..00000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ --r test_requirements.txt -refactordoc -sphinx -sphinx-rtd-theme -wheel -tox diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 1508653a..00000000 --- a/test_requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -coverage -testfixtures diff --git a/tox-requirements.txt b/tox-requirements.txt deleted file mode 100644 index 053148f8..00000000 --- a/tox-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -tox diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1d0c75dc..00000000 --- a/tox.ini +++ /dev/null @@ -1,46 +0,0 @@ -[tox] -envlist = cp{27,34,35,36,37,38,39,310,311,312},pp{2,3},flake8 -minversion=2.7 - -[testenv] -recreate = True -# We use python -m to avoid issues on windows when upgradin pip -# We use -q to avoid issues with unicode errors in the progress bar -install_command = python -m pip install -q {packages} -passenv = - SHOW_TEST_ENV - PYTHONUNBUFFERED - LANG - LOCALE_ARCHIVE -basepython = - cp27: {env:TOXPY27:python2.7} - cp34: {env:TOXPY34:python3.4} - cp35: {env:TOXPY35:python3.5} - cp36: {env:TOXPY36:python3.6} - cp37: {env:TOXPY37:python3.7} - cp38: {env:TOXPY38:python3.8} - cp39: {env:TOXPY38:python3.9} - cp310: {env:TOXPY310:python3.10} - cp311: {env:TOXPY311:python3.12} - cp312: {env:TOXPY312:python3.12} - pp2: {env:TOXPYPY:pypy} - pp3: {env:TOXPYPY3:pypy3} - -commands = - pip install -q -rtest_requirements.txt - pip --version - coverage run --branch -m unittest discover -v -t . haas - python -m haas haas - -[testenv:flake8] -basepython = python3 -skip_install = true -deps = flake8 -commands = flake8 - -[flake8] -exclude = - .tox, - .git, - __pycache__, - docs/source/conf.py From 6b3fabcbfe44d5b9af36a89f1e2f624631c52068 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Tue, 5 Dec 2023 23:00:48 +0200 Subject: [PATCH 6/8] Update changelog --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index be709ec0..29689df6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Changes since version 0.9.0 =========================== +* Replace ``setup.py`` with ``pyproject.toml`` (#199). + Version 0.9.0 ============= From 13d770e4e7599a3a8b9f82b54d13ec95f5a2db67 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Tue, 5 Dec 2023 23:03:33 +0200 Subject: [PATCH 7/8] Minimum setuptools-scm version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4dde42d4..c65c84a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ verbose = "haas.plugins.result_handler:VerboseTestResultHandler" timing = "haas.plugins.result_handler:TimingResultHandler" [build-system] -requires = ["setuptools", "setuptools-scm"] +requires = ["setuptools", "setuptools-scm >= 8.0"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] From fe3229ce9e38ac50ad03b2b31861f15ed540ce56 Mon Sep 17 00:00:00 2001 From: Simon Jagoe Date: Tue, 5 Dec 2023 23:12:01 +0200 Subject: [PATCH 8/8] Don't dynamically generate the version --- haas/__init__.py | 5 +---- pyproject.toml | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/haas/__init__.py b/haas/__init__.py index 9166c6b1..ef68ddea 100644 --- a/haas/__init__.py +++ b/haas/__init__.py @@ -8,10 +8,7 @@ import logging -try: - from haas._version import version as __version__ -except ImportError: # pragma: no cover - __version__ = 'notset' +__version__ = '0.10.0.dev1' class NullHandler(logging.Handler): # pragma: no cover diff --git a/pyproject.toml b/pyproject.toml index c65c84a2..438e211a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,9 @@ packages = [ "haas.plugins.tests", ] +[tool.setuptools.dynamic] +version = {attr = "haas.__version__"} + [project.scripts] haas = "haas.main:main" @@ -67,8 +70,5 @@ verbose = "haas.plugins.result_handler:VerboseTestResultHandler" timing = "haas.plugins.result_handler:TimingResultHandler" [build-system] -requires = ["setuptools", "setuptools-scm >= 8.0"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" - -[tool.setuptools_scm] -version_file = "haas/_version.py"