From 59201a01422c8e397a8fac3f77af66f42c61c2ce Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Wed, 18 Nov 2020 13:46:45 +0100 Subject: [PATCH 1/4] Unify the pure-python templates. This is done by adding a `--with-pypy` switch on the command line. `.meta.cfg` stores whether PyPy is supported or not. --- config/README.rst | 7 +- config/buildout-recipe/tests.yml | 56 ---------------- .../buildout-recipe/{tox.ini => tox.ini.in} | 0 config/config-package.py | 45 ++++++++++--- .../tests.yml => default/tests.yml.in} | 2 +- config/pure-python-without-pypy/packages.txt | 7 -- config/pure-python-without-pypy/tox.ini | 65 ------------------- config/pure-python/packages.txt | 1 + config/pure-python/tests.yml | 56 ---------------- config/pure-python/{tox.ini => tox.ini.in} | 6 +- 10 files changed, 41 insertions(+), 204 deletions(-) delete mode 100644 config/buildout-recipe/tests.yml rename config/buildout-recipe/{tox.ini => tox.ini.in} (100%) rename config/{pure-python-without-pypy/tests.yml => default/tests.yml.in} (96%) delete mode 100644 config/pure-python-without-pypy/packages.txt delete mode 100644 config/pure-python-without-pypy/tox.ini delete mode 100644 config/pure-python/tests.yml rename config/pure-python/{tox.ini => tox.ini.in} (92%) diff --git a/config/README.rst b/config/README.rst index 3eb0dec..9ab70db 100644 --- a/config/README.rst +++ b/config/README.rst @@ -25,11 +25,6 @@ packages: - Configuration for a pure python package which supports PyPy. -* pure-python-without-pypy - - - Configuration for a pure python package which does not supports PyPy, - e. g. the packages Zope depends on. - Contents -------- @@ -117,6 +112,8 @@ The following arguments are supported. --no-push Avoid pushing at the end of the configuration run. +--with-pypy + Enable PyPy support. (Only needed one time as it is stored in .meta.cfg.) Options +++++++ diff --git a/config/buildout-recipe/tests.yml b/config/buildout-recipe/tests.yml deleted file mode 100644 index b1b950e..0000000 --- a/config/buildout-recipe/tests.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/buildout-recipe -name: tests - -on: - push: - branches: [ master ] - pull_request: - schedule: - - cron: '0 12 * * 0' # run once a week on Sunday - -jobs: - build: - strategy: - matrix: - config: - # [Python version, tox env] - - ["3.8", "lint"] - - ["2.7", "py27"] - - ["3.5", "py35"] - - ["3.6", "py36"] - - ["3.7", "py37"] - - ["3.8", "py38"] - - ["3.9", "py39"] - - ["pypy2", "pypy"] - - ["pypy3", "pypy3"] - - ["3.8", "coverage"] - - runs-on: ubuntu-latest - name: ${{ matrix.config[1] }} - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.config[0] }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.*', 'tox.ini') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox - - name: Test - run: tox -e ${{ matrix.config[1] }} - - name: Coverage - if: matrix.config[1] == 'coverage' - run: | - pip install coveralls coverage-python-version - coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/config/buildout-recipe/tox.ini b/config/buildout-recipe/tox.ini.in similarity index 100% rename from config/buildout-recipe/tox.ini rename to config/buildout-recipe/tox.ini.in diff --git a/config/config-package.py b/config/config-package.py index 7c7fe56..cc182e5 100755 --- a/config/config-package.py +++ b/config/config-package.py @@ -12,6 +12,12 @@ # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/{config_type} """ +TESTS_MATRIX_PYPY = """ + - ["pypy2", "pypy"] + - ["pypy3", "pypy3"]""" +TOX_INI_PYPY = """ + pypy, + pypy3,""" def call(*args, capture_output=False): @@ -49,12 +55,17 @@ def copy_with_meta(source, destination, config_type, **kw): dest='no_push', action='store_true', help='Prevent direct push.') +parser.add_argument( + '--with-pypy', + dest='with_pypy', + action='store_true', + default=False, + help='Activate PyPy support if not already configured in .meta.cfg.') parser.add_argument( 'type', choices=[ 'buildout-recipe', 'pure-python', - 'pure-python-without-pypy', ], help='type of the config to be used, see README.rst') @@ -90,6 +101,8 @@ def copy_with_meta(source, destination, config_type, **kw): meta_opts['template'] = config_type meta_opts['commit-id'] = call( 'git', 'log', '-n1', '--format=format:%H', capture_output=True).stdout +with_pypy = meta_opts.getboolean('with-pypy', False) or args.with_pypy +meta_opts['with-pypy'] = str(with_pypy) # Copy template files copy_with_meta( @@ -100,10 +113,8 @@ def copy_with_meta(source, destination, config_type, **kw): default_path / 'editorconfig', path / '.editorconfig', config_type) copy_with_meta( default_path / 'gitignore', path / '.gitignore', config_type) -shutil.copy(config_type_path / 'tox.ini', path) workflows = path / '.github' / 'workflows' workflows.mkdir(parents=True, exist_ok=True) -shutil.copy(config_type_path / 'tests.yml', workflows / 'tests.yml') add_coveragerc = False rm_coveragerc = False @@ -116,17 +127,31 @@ def copy_with_meta(source, destination, config_type, **kw): rm_coveragerc = True -# Modify templates with meta options. -tox_ini_path = path / 'tox.ini' -with open(tox_ini_path) as f_: +# Modify tox.ini with meta options. +with open(config_type_path / 'tox.ini.in') as f_: tox_ini = f_.read() -with open(tox_ini_path, 'w') as f_: +with open(path / 'tox.ini', 'w') as f_: # initialize configuration if not already present fail_under = meta_opts.setdefault('fail-under', '0') - f_.write(tox_ini.format( - coverage_report_options=f'--fail-under={fail_under}')) - + if with_pypy: + additional_environs = TOX_INI_PYPY + else: + additional_environs = '' + f_.write(tox_ini % dict( + coverage_report_options=f'--fail-under={fail_under}', + additional_environs=additional_environs)) + +# Modify GHA config with meta options. +with open(default_path / 'tests.yml.in') as f_: + tests_yml = f_.read() + +with open(workflows / 'tests.yml', 'w') as f_: + if with_pypy: + additional_config = TESTS_MATRIX_PYPY + else: + additional_config = '' + f_.write(tests_yml % dict(additional_config=additional_config)) cwd = os.getcwd() branch_name = f'config-with-{config_type}' diff --git a/config/pure-python-without-pypy/tests.yml b/config/default/tests.yml.in similarity index 96% rename from config/pure-python-without-pypy/tests.yml rename to config/default/tests.yml.in index 7898a16..52cb2fc 100644 --- a/config/pure-python-without-pypy/tests.yml +++ b/config/default/tests.yml.in @@ -21,7 +21,7 @@ jobs: - ["3.6", "py36"] - ["3.7", "py37"] - ["3.8", "py38"] - - ["3.9", "py39"] + - ["3.9", "py39"]%(additional_config)s - ["3.8", "coverage"] runs-on: ubuntu-latest diff --git a/config/pure-python-without-pypy/packages.txt b/config/pure-python-without-pypy/packages.txt deleted file mode 100644 index eb6095a..0000000 --- a/config/pure-python-without-pypy/packages.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Packages configured for the pure python version are listed here. -# Do not edit the file by hand but use the script config-package.py as -# described in README.rst -zLOG -zc.beforestorage -z3c.layer.pagelet -zope.mkzeoinstance diff --git a/config/pure-python-without-pypy/tox.ini b/config/pure-python-without-pypy/tox.ini deleted file mode 100644 index 8b58a88..0000000 --- a/config/pure-python-without-pypy/tox.ini +++ /dev/null @@ -1,65 +0,0 @@ -# Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/pure-python-without-pypy -[tox] -envlist = - lint, - py27, - py35, - py36, - py37, - py38, - py39, - coverage - -[testenv] -usedevelop = true -deps = - zope.testrunner -commands = - zope-testrunner --test-path=src [] -extras = test - -[testenv:lint] -basepython = python3 -skip_install = true -deps = - flake8 - check-manifest - check-python-versions -commands = - flake8 src setup.py - check-manifest - check-python-versions - -[flake8] -doctests = 1 - -[testenv:coverage] -basepython = python3 -deps = - coverage - coverage-python-version - zope.testrunner -commands = - coverage run -m zope.testrunner --test-path=src [] - coverage html - coverage report -m {coverage_report_options} - -[coverage:run] -branch = True -plugins = coverage_python_version -source = src - -[coverage:report] -precision = 2 -exclude_lines = - pragma: no cover - pragma: nocover - except ImportError: - raise NotImplementedError - if __name__ == '__main__': - self.fail - raise AssertionError - -[coverage:html] -directory = htmlcov diff --git a/config/pure-python/packages.txt b/config/pure-python/packages.txt index 18e987a..29a29f5 100644 --- a/config/pure-python/packages.txt +++ b/config/pure-python/packages.txt @@ -9,3 +9,4 @@ zope.app.broken zope.app.appsetup zope.browser zope.dublincore +zLOG diff --git a/config/pure-python/tests.yml b/config/pure-python/tests.yml deleted file mode 100644 index fd5e8d1..0000000 --- a/config/pure-python/tests.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/pure-python -name: tests - -on: - push: - branches: [ master ] - pull_request: - schedule: - - cron: '0 12 * * 0' # run once a week on Sunday - -jobs: - build: - strategy: - matrix: - config: - # [Python version, tox env] - - ["3.8", "lint"] - - ["2.7", "py27"] - - ["3.5", "py35"] - - ["3.6", "py36"] - - ["3.7", "py37"] - - ["3.8", "py38"] - - ["3.9", "py39"] - - ["pypy2", "pypy"] - - ["pypy3", "pypy3"] - - ["3.8", "coverage"] - - runs-on: ubuntu-latest - name: ${{ matrix.config[1] }} - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.config[0] }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.*', 'tox.ini') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox - - name: Test - run: tox -e ${{ matrix.config[1] }} - - name: Coverage - if: matrix.config[1] == 'coverage' - run: | - pip install coveralls coverage-python-version - coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/config/pure-python/tox.ini b/config/pure-python/tox.ini.in similarity index 92% rename from config/pure-python/tox.ini rename to config/pure-python/tox.ini.in index 3560fe1..2605e85 100644 --- a/config/pure-python/tox.ini +++ b/config/pure-python/tox.ini.in @@ -4,13 +4,11 @@ envlist = lint, py27, - pypy2, py35, py36, py37, py38, - py39, - pypy3, + py39,%(additional_environs)s coverage [testenv] @@ -45,7 +43,7 @@ deps = commands = coverage run -m zope.testrunner --test-path=src [] coverage html - coverage report -m {coverage_report_options} + coverage report -m %(coverage_report_options)s [coverage:run] branch = True From bcb6eca09d4fbd3fe4e10cb89942adecee9fee58 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Wed, 18 Nov 2020 13:51:21 +0100 Subject: [PATCH 2/4] Move flake8 config back to `setup.cfg`. --- config/buildout-recipe/setup.cfg | 12 ++++++++++++ config/buildout-recipe/tox.ini.in | 5 ----- config/config-package.py | 2 +- config/{default => pure-python}/setup.cfg | 3 +++ config/pure-python/tox.ini.in | 3 --- 5 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 config/buildout-recipe/setup.cfg rename config/{default => pure-python}/setup.cfg (79%) diff --git a/config/buildout-recipe/setup.cfg b/config/buildout-recipe/setup.cfg new file mode 100644 index 0000000..45fe899 --- /dev/null +++ b/config/buildout-recipe/setup.cfg @@ -0,0 +1,12 @@ +[bdist_wheel] +universal = 1 + +[flake8] +doctests = 1 +# provided to doctests by buildoutSetUp() +builtins = write, system, cat, join + +[check-manifest] +ignore = + .editorconfig + .meta.cfg diff --git a/config/buildout-recipe/tox.ini.in b/config/buildout-recipe/tox.ini.in index 6703399..1defa02 100644 --- a/config/buildout-recipe/tox.ini.in +++ b/config/buildout-recipe/tox.ini.in @@ -33,11 +33,6 @@ commands = check-manifest check-python-versions -[flake8] -doctests = 1 -# provided to doctests by buildoutSetUp() -builtins = write, system, cat, join - [testenv:coverage] basepython = python3 setenv = diff --git a/config/config-package.py b/config/config-package.py index cc182e5..739fbb2 100755 --- a/config/config-package.py +++ b/config/config-package.py @@ -106,7 +106,7 @@ def copy_with_meta(source, destination, config_type, **kw): # Copy template files copy_with_meta( - default_path / 'setup.cfg', path / 'setup.cfg', config_type) + config_type_path / 'setup.cfg', path / 'setup.cfg', config_type) copy_with_meta( default_path / 'MANIFEST.in', path / 'MANIFEST.in', config_type) copy_with_meta( diff --git a/config/default/setup.cfg b/config/pure-python/setup.cfg similarity index 79% rename from config/default/setup.cfg rename to config/pure-python/setup.cfg index 968868e..6bff33f 100644 --- a/config/default/setup.cfg +++ b/config/pure-python/setup.cfg @@ -1,6 +1,9 @@ [bdist_wheel] universal = 1 +[flake8] +doctests = 1 + [check-manifest] ignore = .editorconfig diff --git a/config/pure-python/tox.ini.in b/config/pure-python/tox.ini.in index 2605e85..73719a8 100644 --- a/config/pure-python/tox.ini.in +++ b/config/pure-python/tox.ini.in @@ -31,9 +31,6 @@ commands = check-manifest check-python-versions -[flake8] -doctests = 1 - [testenv:coverage] basepython = python3 deps = From 721aee551db5304e94efb91e9e4d1ccb171e307e Mon Sep 17 00:00:00 2001 From: Steffen Allner Date: Wed, 18 Nov 2020 14:48:18 +0100 Subject: [PATCH 3/4] Clean package log to make room for gocept packages. --- config/buildout-recipe/packages.txt | 6 ++++-- config/pure-python/packages.txt | 12 +++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/config/buildout-recipe/packages.txt b/config/buildout-recipe/packages.txt index 46a9da2..dc4bee9 100644 --- a/config/buildout-recipe/packages.txt +++ b/config/buildout-recipe/packages.txt @@ -1,4 +1,6 @@ -# Packages configured as buildout recipe are listed here. +# Packages configured for the pure python version are listed here. # Do not edit the file by hand but use the script config-package.py as # described in README.rst -z3c.recipe.tag +# +# This was cleaned for gocept packages and has to be merged by hand when merged +# from upstram diff --git a/config/pure-python/packages.txt b/config/pure-python/packages.txt index 29a29f5..dc4bee9 100644 --- a/config/pure-python/packages.txt +++ b/config/pure-python/packages.txt @@ -1,12 +1,6 @@ # Packages configured for the pure python version are listed here. # Do not edit the file by hand but use the script config-package.py as # described in README.rst -zope.authentication -z3c.wizard -zope.browsermenu -zope.app.publication -zope.app.broken -zope.app.appsetup -zope.browser -zope.dublincore -zLOG +# +# This was cleaned for gocept packages and has to be merged by hand when merged +# from upstram From db8a0ab64ca2630b63dc31d30cb7a341401cbdfd Mon Sep 17 00:00:00 2001 From: Steffen Allner Date: Tue, 24 Nov 2020 10:27:36 +0100 Subject: [PATCH 4/4] WIP-branch for pytest support and incremental version specification. --- config/buildout-recipe/tox.ini.in | 10 +--- config/config-package.py | 87 +++++++++++++++++++++++++++++-- config/default/MANIFEST.in | 2 +- config/default/gitignore | 1 + config/default/tests.yml.in | 10 +--- config/pure-python/tox.ini.in | 8 +-- config/pytest/coveragerc | 27 ++++++++++ config/pytest/packages.txt | 7 +++ config/pytest/setup.cfg | 10 ++++ config/pytest/tox.ini.in | 59 +++++++++++++++++++++ 10 files changed, 192 insertions(+), 29 deletions(-) create mode 100644 config/pytest/coveragerc create mode 100644 config/pytest/packages.txt create mode 100644 config/pytest/setup.cfg create mode 100644 config/pytest/tox.ini.in diff --git a/config/buildout-recipe/tox.ini.in b/config/buildout-recipe/tox.ini.in index 1defa02..1f90d75 100644 --- a/config/buildout-recipe/tox.ini.in +++ b/config/buildout-recipe/tox.ini.in @@ -2,15 +2,7 @@ # https://github.com/zopefoundation/meta/tree/master/config/buildout-recipe [tox] envlist = - lint, - py27, - pypy, - py35, - py36, - py37, - py38, - py39, - pypy3, + lint,%(python_environs)s%(additional_environs)s coverage [testenv] diff --git a/config/config-package.py b/config/config-package.py index 739fbb2..184b55c 100755 --- a/config/config-package.py +++ b/config/config-package.py @@ -10,7 +10,7 @@ META_HINT = """\ # Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/{config_type} +# https://github.com/gocept/meta/tree/master/config/{config_type} """ TESTS_MATRIX_PYPY = """ - ["pypy2", "pypy"] @@ -19,6 +19,37 @@ pypy, pypy3,""" +MAX_PYTHON = (3, 9) + + +def get_supported_versions(args): + """Get the supported versions from cli args.""" + versions = [ + (3, minor) + for minor in range(args.min_version[1], MAX_PYTHON[1] + 1) + ] + if args.support_legacy_python: + versions.insert(0, (2, 7)) + return versions + + +def get_tox_ini_versions(versions): + """Return the snippet to be inserted in tox.ini.""" + env_versions = ( + f"py{major}{minor}" + for major, minor in versions + ) + return "".join(f'\n {ver},' for ver in env_versions) + + +def get_test_matrix_versions(versions): + """Return the snippet to be inserted in github actions tests.yml.""" + env_versions = ( + (f"{major}.{minor}", f"py{major}{minor}") + for major, minor in versions + ) + return "".join(f'\n - ["{v1}", "{v2}"]' for v1, v2 in env_versions) + def call(*args, capture_output=False): """Call `args` as a subprocess. @@ -63,11 +94,36 @@ def copy_with_meta(source, destination, config_type, **kw): help='Activate PyPy support if not already configured in .meta.cfg.') parser.add_argument( 'type', - choices=[ + choices=[ 'buildout-recipe', 'pure-python', + 'pytest', ], help='type of the config to be used, see README.rst') +parser.add_argument( + '--with-py27', + action='store_true', dest='support_legacy_python', default=False, +) +parser.add_argument( + '--with-py35', '--py3-only', + action='store_const', dest='min_version', default=(3, 6), const=(3, 5), +) +parser.add_argument( + '--with-py36-plus', + action='store_const', dest='min_version', const=(3, 6), +) +parser.add_argument( + '--with-py37-plus', + action='store_const', dest='min_version', const=(3, 7), +) +parser.add_argument( + '--with-py38-plus', + action='store_const', dest='min_version', const=(3, 8), +) +parser.add_argument( + '--with-py39-plus', + action='store_const', dest='min_version', const=(3, 9), +) args = parser.parse_args() @@ -103,6 +159,9 @@ def copy_with_meta(source, destination, config_type, **kw): 'git', 'log', '-n1', '--format=format:%H', capture_output=True).stdout with_pypy = meta_opts.getboolean('with-pypy', False) or args.with_pypy meta_opts['with-pypy'] = str(with_pypy) +support_legacy_python = meta_opts.getboolean( + 'support_legacy_python', False) or args.support_legacy_python +meta_opts['support_legacy_python'] = str(support_legacy_python) # Copy template files copy_with_meta( @@ -126,6 +185,22 @@ def copy_with_meta(source, destination, config_type, **kw): elif (path / '.coveragerc').exists(): rm_coveragerc = True +# Calculate and format supported versions +versions = get_supported_versions(args) +versions_config = get_test_matrix_versions(versions) +python_environs = get_tox_ini_versions(versions) + + +# Modify setup.cfg with meta options. +with open(config_type_path / 'setup.cfg') as f_: + setup_cfg = f_.read() + +with open(path / 'setup.cfg', 'w') as f_: + universal_wheel = 0 + if support_legacy_python: + universal_wheel = 1 + f_.write(setup_cfg % dict(universal_wheel=universal_wheel)) + # Modify tox.ini with meta options. with open(config_type_path / 'tox.ini.in') as f_: @@ -140,6 +215,7 @@ def copy_with_meta(source, destination, config_type, **kw): additional_environs = '' f_.write(tox_ini % dict( coverage_report_options=f'--fail-under={fail_under}', + python_environs=python_environs, additional_environs=additional_environs)) # Modify GHA config with meta options. @@ -147,11 +223,14 @@ def copy_with_meta(source, destination, config_type, **kw): tests_yml = f_.read() with open(workflows / 'tests.yml', 'w') as f_: + if with_pypy: additional_config = TESTS_MATRIX_PYPY else: additional_config = '' - f_.write(tests_yml % dict(additional_config=additional_config)) + f_.write(tests_yml % dict( + version_config=versions_config, + additional_config=additional_config)) cwd = os.getcwd() branch_name = f'config-with-{config_type}' @@ -167,7 +246,7 @@ def copy_with_meta(source, destination, config_type, **kw): with open('.meta.cfg', 'w') as meta_f: meta_f.write( '# Generated from:\n' - '# https://github.com/zopefoundation/meta/tree/master/config/' + '# https://github.com/gocept/meta/tree/master/config/' f'{config_type}\n') meta_cfg.write(meta_f) diff --git a/config/default/MANIFEST.in b/config/default/MANIFEST.in index ed55f72..d5d6b91 100644 --- a/config/default/MANIFEST.in +++ b/config/default/MANIFEST.in @@ -1,7 +1,7 @@ include *.rst include *.txt include buildout.cfg -include tox.ini +include *.ini include .coveragerc recursive-include docs *.bat diff --git a/config/default/gitignore b/config/default/gitignore index 26e0881..a0a85f1 100644 --- a/config/default/gitignore +++ b/config/default/gitignore @@ -10,6 +10,7 @@ __pycache__/ bin/ build/ +coverage-report/ coverage.xml develop-eggs/ dist/ diff --git a/config/default/tests.yml.in b/config/default/tests.yml.in index 52cb2fc..e8a5fba 100644 --- a/config/default/tests.yml.in +++ b/config/default/tests.yml.in @@ -1,4 +1,4 @@ -# Generated from: + # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python name: tests @@ -15,13 +15,7 @@ jobs: matrix: config: # [Python version, tox env] - - ["3.8", "lint"] - - ["2.7", "py27"] - - ["3.5", "py35"] - - ["3.6", "py36"] - - ["3.7", "py37"] - - ["3.8", "py38"] - - ["3.9", "py39"]%(additional_config)s + - ["3.8", "lint"]%(version_config)s%(additional_config)s - ["3.8", "coverage"] runs-on: ubuntu-latest diff --git a/config/pure-python/tox.ini.in b/config/pure-python/tox.ini.in index 73719a8..e4f9d94 100644 --- a/config/pure-python/tox.ini.in +++ b/config/pure-python/tox.ini.in @@ -2,13 +2,7 @@ # https://github.com/zopefoundation/meta/tree/master/config/pure-python [tox] envlist = - lint, - py27, - py35, - py36, - py37, - py38, - py39,%(additional_environs)s + lint,%(python_environs)s%(additional_environs)s coverage [testenv] diff --git a/config/pytest/coveragerc b/config/pytest/coveragerc new file mode 100644 index 0000000..7d9ea65 --- /dev/null +++ b/config/pytest/coveragerc @@ -0,0 +1,27 @@ +[run] +source = {package_name} +plugins = coverage_python_version +branch = true +parallel = true + +[paths] +source = + src/ + .tox/*/lib/python*/site-packages/ + .tox/pypy*/site-packages/ + +[report] +precision = 2 +exclude_lines = + pragma: no cover + pragma: nocover + except ImportError: + raise NotImplementedError + if __name__ == '__main__': + self.fail + raise AssertionError +omit = */generations/evolve*.py + + +[html] +directory = htmlcov diff --git a/config/pytest/packages.txt b/config/pytest/packages.txt new file mode 100644 index 0000000..a6c907f --- /dev/null +++ b/config/pytest/packages.txt @@ -0,0 +1,7 @@ +# Packages configured for the pure python version are listed here. +# Do not edit the file by hand but use the script config-package.py as +# described in README.rst +# +# This was cleaned for gocept packages and has to be merged by hand when merged +# from upstram +gocept.reference diff --git a/config/pytest/setup.cfg b/config/pytest/setup.cfg new file mode 100644 index 0000000..9423e03 --- /dev/null +++ b/config/pytest/setup.cfg @@ -0,0 +1,10 @@ +[bdist_wheel] +universal = %(universal_wheel)s + +[flake8] +doctests = 1 + +[check-manifest] +ignore = + .editorconfig + .meta.cfg diff --git a/config/pytest/tox.ini.in b/config/pytest/tox.ini.in new file mode 100644 index 0000000..ba8678e --- /dev/null +++ b/config/pytest/tox.ini.in @@ -0,0 +1,59 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python +[tox] +envlist = + lint,%(python_environs)s%(additional_environs)s + coverage + +[testenv] +usedevelop = true +deps = + pytest + pytest-rerunfailures +commands = + pytest src [] +extras = test + +[testenv:lint] +basepython = python3 +skip_install = true +deps = + flake8 + check-manifest + check-python-versions +commands = + flake8 src setup.py + check-manifest + check-python-versions + +[testenv:coverage] +basepython = python3 +deps = + coverage + coverage-python-version + pytest +commands = + coverage erase + coverage run -m pytest src + coverage combine + coverage html + coverage report -m %(coverage_report_options)s + +[coverage:run] +branch = True +plugins = coverage_python_version +source = src + +[coverage:report] +precision = 2 +exclude_lines = + pragma: no cover + pragma: nocover + except ImportError: + raise NotImplementedError + if __name__ == '__main__': + self.fail + raise AssertionError + +[coverage:html] +directory = htmlcov