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/.github/workflows/test.yml b/.github/workflows/test.yml index 69e9d743..a47d6d57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,24 +22,24 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + - name: Install poetry + run: pipx install poetry - name: Setup python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install run: | - pip install -e . - pip install -r "test_requirements.txt" - pip --version + poetry install --with=dev --without=docs - name: Run tests with unittest run: | - coverage run --branch -m unittest discover -v -t . haas + poetry run coverage run --branch -m unittest discover -v -t . haas - name: Run tests with haas run: | - python -m haas haas + poetry run python -m haas haas - name: Print coverage report run: | - coverage report + poetry run coverage report lint: runs-on: ubuntu-latest 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/CHANGES.rst b/CHANGES.rst index be709ec0..37fa5ba4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,12 @@ Changes since version 0.9.0 =========================== +Packaging +--------- + +* Replace ``setup.py`` and setuptools with ``pyproject.toml`` and + poetry (#198). + Version 0.9.0 ============= diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 8d4aee16..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include LICENSE.txt -include *.rst -include *requirements.txt -include tox.ini -recursive-include docs *.rst 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/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/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/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/haas/__init__.py b/haas/__init__.py index 280b375d..1593e40b 100644 --- a/haas/__init__.py +++ b/haas/__init__.py @@ -6,13 +6,10 @@ # of the 3-clause BSD license. See the LICENSE.txt file for details. from __future__ import absolute_import, unicode_literals -try: - from haas._version import version as __version__ -except ImportError: # pragma: no cover - __version__ = 'notset' - import logging +__version__ = 'notset' + 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..b9b39734 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[tool.poetry] +name = "haas" +version = "0.0.0" +description = "Extensible Python Test Runner" +authors = ["Simon Jagoe "] +license = "BSD" +readme = "README.rst" +repository = "https://github.com/scalative/haas" +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", +] +include = [ + { path = "docs", format = "sdist" }, + { path = "*.rst", format = "sdist" }, + { path = "*requirements.txt", format = "sdist" }, + { path = "tox.ini", format = "sdist" }, +] + +[tool.poetry.scripts] +haas = "haas.main:main" + +[tool.poetry.plugins."haas.hooks.environment"] +coverage = "haas.plugins.coverage:Coverage" + +[tool.poetry.plugins."haas.discovery"] +default = "haas.plugins.discoverer:Discoverer" + +[tool.poetry.plugins."haas.runner"] +default = "haas.plugins.runner:BaseTestRunner" +parallel = "haas.plugins.parallel_runner:ParallelTestRunner" + +[tool.poetry.plugins."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" + +[tool.poetry.dependencies] +python = "^3.7" +statistics = ">= 1.0" +stevedore = ">= 3.5.2" + +[tool.poetry.group.dev.dependencies] +coverage = ">= 7.0.0" +testfixtures = ">= 7.0.0" + +[tool.poetry.group.docs.dependencies] +refactordoc = ">= 0.3.1" +sphinx = ">= 5.3.0" +sphinx-rtd-theme = ">= 2.0.0" + +[build-system] +requires = ["poetry-core >= 1.0.0", "poetry-dynamic-versioning >= 1.0.0, < 2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" + +[tool.poetry-dynamic-versioning] +enable = true + +[tool.poetry-dynamic-versioning.substitution] 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] 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', - ] - }, - ) diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index ff0b4f14..00000000 --- a/test_requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage -unittest2; python_version == '2.6' -mock; python_version < '3.3' -testfixtures diff --git a/tox-requirements.txt b/tox-requirements.txt deleted file mode 100644 index c78bdc39..00000000 --- a/tox-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -tox < 3.0.0; python_version == '3.3' -tox; python_version != '3.3' -virtualenv == 15.2.0; python_version == '3.3' 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