From 52e36fcf91654cfcf820cef1776ba0eb65f65729 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Wed, 27 Jan 2021 08:10:08 +0100 Subject: [PATCH] Config with pure python (#2) * Lint the code. * Add support for Python 3.7, 3.8 and 3.9. * Drop support for Python 3.4. --- .coveragerc | 7 --- .editorconfig | 39 ++++++++++++++++ .github/workflows/tests.yml | 57 +++++++++++++++++++++++ .gitignore | 28 ++++++++---- .meta.toml | 32 +++++++++++++ .travis.yml | 21 --------- CHANGES.rst | 6 ++- MANIFEST.in | 10 +++-- bootstrap.py | 52 --------------------- setup.cfg | 18 ++++++++ setup.py | 12 +++-- src/zope/__init__.py | 2 +- src/zope/app/__init__.py | 2 +- src/zope/app/catalog/attribute.py | 7 +-- src/zope/app/catalog/browser/catalog.py | 1 + src/zope/app/catalog/browser/tests.py | 7 --- src/zope/app/catalog/catalog.py | 5 +-- src/zope/app/catalog/field.py | 7 +-- src/zope/app/catalog/interfaces.py | 5 +-- src/zope/app/catalog/keyword.py | 5 +-- src/zope/app/catalog/tests.py | 17 ++++--- src/zope/app/catalog/text.py | 7 +-- tox.ini | 60 ++++++++++++++++++++++++- 23 files changed, 262 insertions(+), 145 deletions(-) delete mode 100644 .coveragerc create mode 100644 .editorconfig create mode 100644 .github/workflows/tests.yml create mode 100644 .meta.toml delete mode 100644 .travis.yml delete mode 100644 bootstrap.py diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f205e92..0000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -source = src - -[report] -exclude_lines = - pragma: no cover - if __name__ == '__main__': diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f3e46f5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python +# +# EditorConfig Configuration file, for more details see: +# http://EditorConfig.org +# EditorConfig is a convention description, that could be interpreted +# by multiple editors to enforce common coding conventions for specific +# file types + +# top-most EditorConfig file: +# Will ignore other EditorConfig files in Home directory or upper tree level. +root = true + + +[*] # For All Files +# Unix-style newlines with a newline ending every file +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +# Set default charset +charset = utf-8 +# Indent style default +indent_style = space +# Max Line Length - a hard line wrap, should be disabled +max_line_length = off + +[*.{py,cfg,ini}] +# 4 space indentation +indent_size = 4 + +[*.{yml,zpt,pt,dtml}] +# 2 space indentation +indent_size = 2 + +[{Makefile,.gitmodules}] +# Tab indentation (no size specified, but view as 4 spaces) +indent_style = tab +indent_size = unset +tab_width = unset diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0d787a0 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,57 @@ +# 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-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.config[0] }}- + ${{ 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 --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 6bacfe5..0aadbae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,25 @@ -bin/ -eggs/ -develop-eggs/ -parts/ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python +*.egg-info/ +*.profraw +*.pyc +*.pyo +.coverage +.coverage.* +.eggs/ .installed.cfg -*.py[co] +.mr.developer.cfg +.tox/ __pycache__/ +bin/ build/ +coverage.xml +develop-eggs/ dist/ -*.egg-info/ -.tox/ -.coverage +docs/_build +eggs/ htmlcov/ +lib/ +lib64 +parts/ +pyvenv.cfg diff --git a/.meta.toml b/.meta.toml new file mode 100644 index 0000000..a7ac41a --- /dev/null +++ b/.meta.toml @@ -0,0 +1,32 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python +[meta] +template = "pure-python" +commit-id = "2f8a259d7589d70e4fa73654d5a28f174f0959a0" + +[python] +with-appveyor = false +with-pypy = true +with-legacy-python = true +with-docs = false +with-sphinx-doctests = false + +[coverage] +fail-under = 98 + +[manifest] +additional-rules = [ + "recursive-include src *.gif", + ] + +[flake8] +additional-config = [ + "# F401 imported but unused", + "per-file-ignores =", + " src/zope/app/catalog/attribute.py: F401", + " src/zope/app/catalog/catalog.py: F401", + " src/zope/app/catalog/field.py: F401", + " src/zope/app/catalog/interfaces.py: F401", + " src/zope/app/catalog/keyword.py: F401", + " src/zope/app/catalog/text.py: F401", + ] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f9678cd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: python -sudo: false -python: - - 2.7 - - pypy-5.4.1 - - 3.4 - - 3.5 - - 3.6 -install: - - pip install -U pip setuptools - - pip install -U coverage coveralls - - pip install -U -e .[test] -script: - - coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress -notifications: - email: false -after_success: - - coveralls -cache: pip -before_cache: - - rm -f $HOME/.cache/pip/log/debug.log diff --git a/CHANGES.rst b/CHANGES.rst index e69834c..951f63a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,10 +2,12 @@ CHANGES ======= -4.0.1 (unreleased) +4.1.0 (unreleased) ------------------ -- Nothing changed yet. +- Add support for Python 3.7, 3.8 and 3.9. + +- Drop support for Python 3.4. 4.0.0 (2017-05-05) diff --git a/MANIFEST.in b/MANIFEST.in index 64fdec6..0b5df24 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,11 +1,13 @@ -include *.py -include *.txt +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python include *.rst +include *.txt include buildout.cfg -include .travis.yml include tox.ini -include .coveragerc + recursive-include src *.pt +recursive-include src *.py recursive-include src *.rst +recursive-include src *.txt recursive-include src *.zcml recursive-include src *.gif diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index b5b9c13..0000000 --- a/bootstrap.py +++ /dev/null @@ -1,52 +0,0 @@ -############################################################################## -# -# Copyright (c) 2006 Zope Corporation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""Bootstrap a buildout-based project - -Simply run this script in a directory containing a buildout.cfg. -The script accepts buildout command-line options, so you can -use the -c option to specify an alternate configuration file. - -$Id$ -""" - -import os, shutil, sys, tempfile, urllib2 - -tmpeggs = tempfile.mkdtemp() - -ez = {} -exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' - ).read() in ez -ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) - -import pkg_resources - -cmd = 'from setuptools.command.easy_install import main; main()' -if sys.platform == 'win32': - cmd = '"%s"' % cmd # work around spawn lamosity on windows - -ws = pkg_resources.working_set -assert os.spawnle( - os.P_WAIT, sys.executable, sys.executable, - '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout', - dict(os.environ, - PYTHONPATH= - ws.find(pkg_resources.Requirement.parse('setuptools')).location - ), - ) == 0 - -ws.add_entry(tmpeggs) -ws.require('zc.buildout') -import zc.buildout.buildout -zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) -shutil.rmtree(tmpeggs) diff --git a/setup.cfg b/setup.cfg index 2a9acf1..fe6ffe4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,20 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python [bdist_wheel] universal = 1 + +[flake8] +doctests = 1 +# F401 imported but unused +per-file-ignores = + src/zope/app/catalog/attribute.py: F401 + src/zope/app/catalog/catalog.py: F401 + src/zope/app/catalog/field.py: F401 + src/zope/app/catalog/interfaces.py: F401 + src/zope/app/catalog/keyword.py: F401 + src/zope/app/catalog/text.py: F401 + +[check-manifest] +ignore = + .editorconfig + .meta.toml diff --git a/setup.py b/setup.py index 7f852ad..d1ff282 100644 --- a/setup.py +++ b/setup.py @@ -22,10 +22,12 @@ import os from setuptools import setup, find_packages + def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() + tests_require = [ 'zope.app.appsetup', 'zope.app.basicskin >= 4.0.0', @@ -55,7 +57,7 @@ def read(*rnames): ] setup(name='zope.app.catalog', - version='4.0.1.dev0', + version='4.1.0.dev0', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description='Management pages for Zope Catalog', @@ -63,7 +65,7 @@ def read(*rnames): read('README.rst') + '\n\n' + read('CHANGES.rst') - ), + ), keywords="zope3 catalog index", classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -74,9 +76,11 @@ def read(*rnames): 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Natural Language :: English', @@ -99,4 +103,4 @@ def read(*rnames): ], include_package_data=True, zip_safe=False, -) + ) diff --git a/src/zope/__init__.py b/src/zope/__init__.py index 2cdb0e4..656dc0f 100644 --- a/src/zope/__init__.py +++ b/src/zope/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover +__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover diff --git a/src/zope/app/__init__.py b/src/zope/app/__init__.py index 2cdb0e4..656dc0f 100644 --- a/src/zope/app/__init__.py +++ b/src/zope/app/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover +__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover diff --git a/src/zope/app/catalog/attribute.py b/src/zope/app/catalog/attribute.py index e578591..d8745ad 100644 --- a/src/zope/app/catalog/attribute.py +++ b/src/zope/app/catalog/attribute.py @@ -11,8 +11,5 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Index interface-defined attributes - -$Id$ -""" -from zope.catalog.attribute import AttributeIndex # BBB +"""Index interface-defined attributes.""" +from zope.catalog.attribute import AttributeIndex # BBB diff --git a/src/zope/app/catalog/browser/catalog.py b/src/zope/app/catalog/browser/catalog.py index 5fd4609..cb88e74 100644 --- a/src/zope/app/catalog/browser/catalog.py +++ b/src/zope/app/catalog/browser/catalog.py @@ -16,6 +16,7 @@ """ from zope.catalog.interfaces import ICatalog + class Advanced(object): "Provides a user interface for configuring a catalog" diff --git a/src/zope/app/catalog/browser/tests.py b/src/zope/app/catalog/browser/tests.py index 2e2f6ff..5a3ab82 100644 --- a/src/zope/app/catalog/browser/tests.py +++ b/src/zope/app/catalog/browser/tests.py @@ -13,10 +13,8 @@ ############################################################################## """Functional tests for zope.app.catalog - """ import doctest -import unittest import re from zope.testing import renormalizing @@ -36,7 +34,6 @@ def http(query_str, *args, **kwargs): return _http(wsgi_app, query_str, *args, **kwargs) - def test_suite(): checker = renormalizing.RENormalizing(( (re.compile("HTTP/1.0"), "HTTP/1.1"), @@ -53,7 +50,3 @@ def test_suite(): ) suite.layer = AppCatalogLayer return suite - - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') diff --git a/src/zope/app/catalog/catalog.py b/src/zope/app/catalog/catalog.py index 356d5ef..1f67cb5 100644 --- a/src/zope/app/catalog/catalog.py +++ b/src/zope/app/catalog/catalog.py @@ -11,10 +11,7 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Catalog - -$Id$ -""" +"""Catalog.""" # BBB from zope.catalog.catalog import ( diff --git a/src/zope/app/catalog/field.py b/src/zope/app/catalog/field.py index 7fccec4..de10927 100644 --- a/src/zope/app/catalog/field.py +++ b/src/zope/app/catalog/field.py @@ -11,9 +11,6 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Field catalog indexes +"""Field catalog indexes.""" -$Id$ -""" - -from zope.catalog.field import IFieldIndex, FieldIndex # BBB +from zope.catalog.field import IFieldIndex, FieldIndex # BBB diff --git a/src/zope/app/catalog/interfaces.py b/src/zope/app/catalog/interfaces.py index fc42f27..203c5f6 100644 --- a/src/zope/app/catalog/interfaces.py +++ b/src/zope/app/catalog/interfaces.py @@ -11,10 +11,7 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Catalog Interfaces - -$Id$ -""" +"""Catalog Interfaces.""" # BBB from zope.catalog.interfaces import ( diff --git a/src/zope/app/catalog/keyword.py b/src/zope/app/catalog/keyword.py index 7e5efd1..dbee1c0 100644 --- a/src/zope/app/catalog/keyword.py +++ b/src/zope/app/catalog/keyword.py @@ -11,10 +11,7 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Keyword catalog index - -$Id:$ -""" +"""Keyword catalog index.""" # BBB from zope.catalog.keyword import ( diff --git a/src/zope/app/catalog/tests.py b/src/zope/app/catalog/tests.py index cf254c2..978a042 100644 --- a/src/zope/app/catalog/tests.py +++ b/src/zope/app/catalog/tests.py @@ -15,9 +15,16 @@ """ +from zope.schema import SourceText +from zope.index.text.interfaces import ISearchableText +from zope.interface import implementer +from zope.pagetemplate.pagetemplate import PageTemplate +from persistent import Persistent +from zope.container.contained import Contained import importlib import unittest + def _make_import_test(mod_name, attrname): def test(self): mod = importlib.import_module('zope.app.catalog.' + mod_name) @@ -26,6 +33,7 @@ def test(self): return test + class TestBWCImports(unittest.TestCase): for mod_name, attrname in (('attribute', 'AttributeIndex'), @@ -37,15 +45,6 @@ class TestBWCImports(unittest.TestCase): locals()['test_' + mod_name] = _make_import_test(mod_name, attrname) -from zope.container.contained import Contained -from persistent import Persistent -from zope.pagetemplate.pagetemplate import PageTemplate -from zope.interface import implementer -from zope.index.text.interfaces import ISearchableText - -from zope.schema import SourceText - - class IZPTPage(ISearchableText): """ZPT Pages are a persistent implementation of Page Templates.""" diff --git a/src/zope/app/catalog/text.py b/src/zope/app/catalog/text.py index 49a9b58..e2f6e3f 100644 --- a/src/zope/app/catalog/text.py +++ b/src/zope/app/catalog/text.py @@ -11,9 +11,6 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -"""Text catalog indexes +"""Text catalog indexes.""" -$Id$ -""" - -from zope.catalog.text import ITextIndex, TextIndex # BBB +from zope.catalog.text import ITextIndex, TextIndex # BBB diff --git a/tox.ini b/tox.ini index 89b6219..d6b1153 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,65 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python [tox] envlist = - py27, pypy, py34, py35, py36 + lint + py27 + py35 + py36 + py37 + py38 + py39 + pypy + pypy3 + 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 + +[testenv:coverage] +basepython = python3 deps = - .[test] + coverage + coverage-python-version + zope.testrunner +commands = + coverage run -m zope.testrunner --test-path=src [] + coverage html + coverage report -m --fail-under=98 + +[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