From 7dc54c9e072d681a1751d8ad9140bc7812d23a67 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 19 Feb 2021 17:46:22 +0100 Subject: [PATCH 1/4] Configuring for pure-python --- .coveragerc | 8 -- .editorconfig | 39 +++++++ .github/workflows/tests.yml | 57 ++++++++++ .gitignore | 21 +++- .meta.toml | 34 ++++++ .travis.yml | 38 ------- MANIFEST.in | 16 +-- bootstrap.py | 210 ------------------------------------ setup.cfg | 12 +++ tox.ini | 69 +++++++++--- 10 files changed, 227 insertions(+), 277 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 f31f86e..0000000 --- a/.coveragerc +++ /dev/null @@ -1,8 +0,0 @@ -[run] -source = src - -[report] -exclude_lines = - pragma: no cover - if __name__ == '__main__': - raise NotImplementedError 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 05d48da..9a9e9b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,29 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python *.egg-info/ +*.profraw *.pyc +*.pyo .coverage +.coverage.* +.eggs/ .installed.cfg +.mr.developer.cfg .tox/ +.vscode/ __pycache__/ bin/ +build/ +coverage.xml develop-eggs/ +develop/ +dist/ +docs/_build eggs/ -htmlcov/ +etc/ +lib/ +lib64 +log/ +parts/ +pyvenv.cfg +var/ diff --git a/.meta.toml b/.meta.toml new file mode 100644 index 0000000..be71f13 --- /dev/null +++ b/.meta.toml @@ -0,0 +1,34 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python +[meta] +template = "pure-python" +commit-id = "519ffffe1b360ede58b32a375b5f8b26059d8016" + +[python] +with-appveyor = false +with-pypy = true +with-legacy-python = true +with-docs = false +with-sphinx-doctests = false + +[coverage] +fail-under = 84 + +[tox] +testenv-additional = [ + " zcml", + ] + +[manifest] +additional-rules = [ + "recursive-include src *.po", + "recursive-include src *.pot", + "recursive-include testproj *.pt", + "recursive-include testproj *.py", + "recursive-include testproj *.zcml", + ] + +[check-manifest] +ignore-bad-ideas = [ + "src/zope/app/locales/*/LC_MESSAGES/zope.mo", + ] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ea24fcb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: python -dist: xenial - -python: - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8 - - pypy - - pypy3 - -matrix: - include: - - python: 3.6 - name: "Flake8" - install: pip install -U flake8 - script: flake8 --doctests src testproj setup.py - after_success: - -script: - - coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress - -after_success: - - coveralls - -notifications: - email: false - -install: - - pip install -U pip setuptools - - pip install -U coveralls coverage - - pip install -U -e ".[test,zcml,extract]" - -cache: pip - -before_cache: - - rm -f $HOME/.cache/pip/log/debug.log diff --git a/MANIFEST.in b/MANIFEST.in index e57a5e1..30ff807 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,17 +1,17 @@ -include *.py -include *.txt +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python include *.rst +include *.txt include buildout.cfg -include .coveragerc -include .travis.yml include tox.ini -recursive-include src *.po -recursive-include src *.mo -recursive-include src *.pot -recursive-include src *.txt +recursive-include src *.pt +recursive-include src *.py recursive-include src *.rst +recursive-include src *.txt recursive-include src *.zcml +recursive-include src *.po +recursive-include src *.pot recursive-include testproj *.pt recursive-include testproj *.py recursive-include testproj *.zcml diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index a459921..0000000 --- a/bootstrap.py +++ /dev/null @@ -1,210 +0,0 @@ -############################################################################## -# -# Copyright (c) 2006 Zope Foundation 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. -""" - -import os -import shutil -import sys -import tempfile - -from optparse import OptionParser - -__version__ = '2015-07-01' -# See zc.buildout's changelog if this version is up to date. - -tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') - -usage = '''\ -[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] - -Bootstraps a buildout-based project. - -Simply run this script in a directory containing a buildout.cfg, using the -Python that you want bin/buildout to use. - -Note that by using --find-links to point to local resources, you can keep -this script from going over the network. -''' - -parser = OptionParser(usage=usage) -parser.add_option("--version", - action="store_true", default=False, - help=("Return bootstrap.py version.")) -parser.add_option("-t", "--accept-buildout-test-releases", - dest='accept_buildout_test_releases', - action="store_true", default=False, - help=("Normally, if you do not specify a --version, the " - "bootstrap script and buildout gets the newest " - "*final* versions of zc.buildout and its recipes and " - "extensions for you. If you use this flag, " - "bootstrap and buildout will get the newest releases " - "even if they are alphas or betas.")) -parser.add_option("-c", "--config-file", - help=("Specify the path to the buildout configuration " - "file to be used.")) -parser.add_option("-f", "--find-links", - help=("Specify a URL to search for buildout releases")) -parser.add_option("--allow-site-packages", - action="store_true", default=False, - help=("Let bootstrap.py use existing site packages")) -parser.add_option("--buildout-version", - help="Use a specific zc.buildout version") -parser.add_option("--setuptools-version", - help="Use a specific setuptools version") -parser.add_option("--setuptools-to-dir", - help=("Allow for re-use of existing directory of " - "setuptools versions")) - -options, args = parser.parse_args() -if options.version: - print("bootstrap.py version %s" % __version__) - sys.exit(0) - - -###################################################################### -# load/install setuptools - -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen - -ez = {} -if os.path.exists('ez_setup.py'): - exec(open('ez_setup.py').read(), ez) -else: - exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) - -if not options.allow_site_packages: - # ez_setup imports site, which adds site packages - # this will remove them from the path to ensure that incompatible versions - # of setuptools are not in the path - import site - # inside a virtualenv, there is no 'getsitepackages'. - # We can't remove these reliably - if hasattr(site, 'getsitepackages'): - for sitepackage_path in site.getsitepackages(): - # Strip all site-packages directories from sys.path that - # are not sys.prefix; this is because on Windows - # sys.prefix is a site-package directory. - if sitepackage_path != sys.prefix: - sys.path[:] = [x for x in sys.path - if sitepackage_path not in x] - -setup_args = dict(to_dir=tmpeggs, download_delay=0) - -if options.setuptools_version is not None: - setup_args['version'] = options.setuptools_version -if options.setuptools_to_dir is not None: - setup_args['to_dir'] = options.setuptools_to_dir - -ez['use_setuptools'](**setup_args) -import setuptools -import pkg_resources - -# This does not (always?) update the default working set. We will -# do it. -for path in sys.path: - if path not in pkg_resources.working_set.entries: - pkg_resources.working_set.add_entry(path) - -###################################################################### -# Install buildout - -ws = pkg_resources.working_set - -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - -# Fix sys.path here as easy_install.pth added before PYTHONPATH -cmd = [sys.executable, '-c', - 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + - 'from setuptools.command.easy_install import main; main()', - '-mZqNxd', tmpeggs] - -find_links = os.environ.get( - 'bootstrap-testing-find-links', - options.find_links or - ('http://downloads.buildout.org/' - if options.accept_buildout_test_releases else None) - ) -if find_links: - cmd.extend(['-f', find_links]) - -requirement = 'zc.buildout' -version = options.buildout_version -if version is None and not options.accept_buildout_test_releases: - # Figure out the most recent final version of zc.buildout. - import setuptools.package_index - _final_parts = '*final-', '*final' - - def _final_version(parsed_version): - try: - return not parsed_version.is_prerelease - except AttributeError: - # Older setuptools - for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): - return False - return True - - index = setuptools.package_index.PackageIndex( - search_path=[setuptools_path]) - if find_links: - index.add_find_links((find_links,)) - req = pkg_resources.Requirement.parse(requirement) - if index.obtain(req) is not None: - best = [] - bestv = None - for dist in index[req.project_name]: - distv = dist.parsed_version - if _final_version(distv): - if bestv is None or distv > bestv: - best = [dist] - bestv = distv - elif distv == bestv: - best.append(dist) - if best: - best.sort() - version = best[-1].version -if version: - requirement = '=='.join((requirement, version)) -cmd.append(requirement) - -import subprocess -if subprocess.call(cmd) != 0: - raise Exception( - "Failed to execute command:\n%s" % repr(cmd)[1:-1]) - -###################################################################### -# Import and run buildout - -ws.add_entry(tmpeggs) -ws.require(requirement) -import zc.buildout.buildout - -if not [a for a in args if '=' not in a]: - args.append('bootstrap') - -# if -c was provided, we push it back into args for buildout' main function -if options.config_file is not None: - args[0:0] = ['-c', options.config_file] - -zc.buildout.buildout.main(args) -shutil.rmtree(tmpeggs) diff --git a/setup.cfg b/setup.cfg index 2a9acf1..cf76bed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,14 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python [bdist_wheel] universal = 1 + +[flake8] +doctests = 1 + +[check-manifest] +ignore = + .editorconfig + .meta.toml +ignore-bad-ideas = + src/zope/app/locales/*/LC_MESSAGES/zope.mo diff --git a/tox.ini b/tox.ini index df78d33..8991819 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,70 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/pure-python [tox] +minversion = 3.18 envlist = - flake8, py27, pypy, py35, py36, py37, py38, pypy3, coverage + lint + py27 + py35 + py36 + py37 + py38 + py39 + pypy + pypy3 + coverage [testenv] +usedevelop = true +deps = + zope.testrunner commands = - zope-testrunner --test-path=src [] + zope-testrunner --test-path=src {posargs:-vc} extras = test zcml - extract -[testenv:flake8] -basepython = python3.6 +[testenv:lint] +basepython = python3 skip_install = true -deps = flake8 -commands = flake8 --doctests src testproj setup.py +deps = + flake8 + check-manifest + check-python-versions +commands = + flake8 src setup.py + check-manifest + check-python-versions [testenv:coverage] -basepython = python3.6 -usedevelop = true +basepython = python3 +allowlist_externals = + mkdir +deps = + coverage + coverage-python-version + zope.testrunner commands = - coverage run -m zope.testrunner --test-path=src [] - coverage report --show-missing --fail-under=88 -deps = coverage + mkdir -p {toxinidir}/parts/htmlcov + coverage run -m zope.testrunner --test-path=src {posargs:-vc} + coverage html + coverage report -m --fail-under=84 + +[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 = parts/htmlcov From 8b54b9c147f3847c9a6704e6dec3b5d960e470e7 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 19 Feb 2021 17:46:37 +0100 Subject: [PATCH 2/4] Add support for Python 3.9. --- CHANGES.rst | 2 +- setup.py | 1 + src/zope/app/locales/extract.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1f11ede..37c8a52 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ CHANGES 4.2 (unreleased) ---------------- -- Nothing changed yet. +- Add support for Python 3.9. 4.1 (2019-06-24) diff --git a/setup.py b/setup.py index 7e0cc3a..708545e 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ def read(*rnames): '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', diff --git a/src/zope/app/locales/extract.py b/src/zope/app/locales/extract.py index c71f5a0..5a444fc 100644 --- a/src/zope/app/locales/extract.py +++ b/src/zope/app/locales/extract.py @@ -660,7 +660,7 @@ def write(self, s): engine.catalog['default'] = {} catalog.update(engine.catalog['default']) for msgid, locations in list(catalog.items()): - catalog[msgid] = [(l[0], l[1][0]) for l in locations] + catalog[msgid] = [(loc[0], loc[1][0]) for loc in locations] return catalog From 90f896d8d280be53798cf586c0f24f352bb6a143 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Wed, 24 Feb 2021 13:13:12 +0100 Subject: [PATCH 3/4] Configuring for pure-python --- .meta.toml | 1 + tox.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/.meta.toml b/.meta.toml index be71f13..f9b60c7 100644 --- a/.meta.toml +++ b/.meta.toml @@ -17,6 +17,7 @@ fail-under = 84 [tox] testenv-additional = [ " zcml", + " extract", ] [manifest] diff --git a/tox.ini b/tox.ini index 8991819..63aebc8 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ commands = extras = test zcml + extract [testenv:lint] basepython = python3 From db2f0b4043b0eaeb083e41151db212b648a19e9c Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 26 Feb 2021 14:46:53 +0100 Subject: [PATCH 4/4] Configuring for pure-python --- .meta.toml | 3 +++ tox.ini | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.meta.toml b/.meta.toml index f9b60c7..7a59fdb 100644 --- a/.meta.toml +++ b/.meta.toml @@ -33,3 +33,6 @@ additional-rules = [ ignore-bad-ideas = [ "src/zope/app/locales/*/LC_MESSAGES/zope.mo", ] + +[flake8] +additional-sources = "testproj" diff --git a/tox.ini b/tox.ini index 63aebc8..fe6f000 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,7 @@ deps = check-manifest check-python-versions commands = - flake8 src setup.py + flake8 src setup.py testproj check-manifest check-python-versions