diff --git a/config/README.rst b/config/README.rst index b156e96..16af92e 100644 --- a/config/README.rst +++ b/config/README.rst @@ -116,6 +116,11 @@ The following arguments are supported. --with-pypy Enable PyPy support. (Only needed one time as it is stored in .meta.cfg.) +--without-legacy-python + The package does not support Python versions which reached their end-of-life. + (Currently this means dropping support for Python 2.7 and 3.5.) This as well + drops support for PyPy2. (Only needed one time as it is stored in .meta.cfg.) + --with-docs Enable building the documentation using Sphinx. (Only needed one time as it is stored in .meta.cfg.) @@ -124,6 +129,7 @@ The following arguments are supported. Enable running the documentation as doctest using Sphinx. (Only needed one time as it is stored in .meta.cfg.) + Options +++++++ @@ -142,7 +148,10 @@ updated. Example: with-pypy = False with-docs = True with-sphinx-doctests = False + with-legacy-python = True additional-manifest-rules = + additional-flake8-config = + ignore = D203 Meta Options @@ -162,6 +171,9 @@ fail-under with-pypy Does the package support PyPy: True/False +with-legacy-python + Run the tests even on Python 2.7, PyPy2 and Python 3.5: True/False + with-docs Build the documentation via Sphinx: True/False @@ -171,6 +183,11 @@ with-sphinx-doctests additional-manifest-rules Additional rules to be added at the end of the MANIFEST.in file. +additional-flake8-config + Additional configuration options be added at the end of the flake8 + configuration section in ``setup.cfg``. + + Hints ----- diff --git a/config/buildout-recipe/tox.ini.j2 b/config/buildout-recipe/tox.ini.j2 index 34b5ed5..3a9bd6d 100644 --- a/config/buildout-recipe/tox.ini.j2 +++ b/config/buildout-recipe/tox.ini.j2 @@ -1,14 +1,18 @@ [tox] envlist = lint, +{% if with_legacy_python %} py27, py35, +{% endif %} py36, py37, py38, py39, -{% if with_pypy %} +{% if with_pypy and with_legacy_python %} pypy, +{% endif %} +{% if with_pypy %} pypy3, {% endif %} {% if with_docs %} diff --git a/config/config-package.py b/config/config-package.py index d0bb8dc..9c0c3d2 100755 --- a/config/config-package.py +++ b/config/config-package.py @@ -37,7 +37,7 @@ def copy_with_meta(template_name, destination, config_type, **kw): with open(destination, 'w') as f_: f_.write(META_HINT.format(config_type=config_type)) template = jinja_env.get_template(template_name) - f_.write(template.render(**kw)) + f_.write(template.render(config_type=config_type, **kw)) parser = argparse.ArgumentParser( @@ -55,6 +55,14 @@ def copy_with_meta(template_name, destination, config_type, **kw): action='store_true', default=False, help='Activate PyPy support if not already configured in .meta.cfg.') +parser.add_argument( + '--without-legacy-python', + dest='with_legacy_python', + action='store_false', + default=None, + help='Disable support for Python versions which reached their end-of-life.' + ' (aka 2.7 and 3.5) if not already configured in .meta.cfg.' + ' Also disables support for PyPy2.') parser.add_argument( '--with-docs', dest='with_docs', @@ -118,6 +126,11 @@ def copy_with_meta(template_name, 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) +if args.with_legacy_python is None: + with_legacy_python = meta_opts.getboolean('with-legacy-python', True) +else: + with_legacy_python = args.with_legacy_python +meta_opts['with-legacy-python'] = str(with_legacy_python) with_docs = meta_opts.getboolean('with-docs', False) or args.with_docs meta_opts['with-docs'] = str(with_docs) with_sphinx_doctests = meta_opts.getboolean( @@ -125,7 +138,11 @@ def copy_with_meta(template_name, destination, config_type, **kw): meta_opts['with-sphinx-doctests'] = str(with_sphinx_doctests) # Copy template files -copy_with_meta('setup.cfg', path / 'setup.cfg', config_type) +additional_flake8_config = meta_opts.get( + 'additional-flake8-config', '').strip() +copy_with_meta('setup.cfg.j2', path / 'setup.cfg', config_type, + additional_flake8_config=additional_flake8_config, + with_docs=with_docs, with_sphinx_doctests=with_sphinx_doctests) copy_with_meta('editorconfig', path / '.editorconfig', config_type) copy_with_meta('gitignore', path / '.gitignore', config_type) workflows = path / '.github' / 'workflows' @@ -146,10 +163,12 @@ def copy_with_meta(template_name, destination, config_type, **kw): copy_with_meta( 'tox.ini.j2', path / 'tox.ini', config_type, fail_under=fail_under, with_pypy=with_pypy, + with_legacy_python=with_legacy_python, with_docs=with_docs, with_sphinx_doctests=with_sphinx_doctests) copy_with_meta( 'tests.yml.j2', workflows / 'tests.yml', config_type, - with_pypy=with_pypy, with_docs=with_docs) + with_pypy=with_pypy, with_legacy_python=with_legacy_python, + with_docs=with_docs) # Modify MANIFEST.in with meta options diff --git a/config/buildout-recipe/setup.cfg b/config/default/setup.cfg.j2 similarity index 54% rename from config/buildout-recipe/setup.cfg rename to config/default/setup.cfg.j2 index ad7ed17..a986fd0 100644 --- a/config/buildout-recipe/setup.cfg +++ b/config/default/setup.cfg.j2 @@ -3,12 +3,21 @@ universal = 1 [flake8] doctests = 1 +{% if config_type == 'buildout-recipe' %} # provided to doctests by buildoutSetUp() builtins = write, system, cat, join +{% endif %} +{% if additional_flake8_config %} +%(additional_flake8_config)s +{% endif %} [check-manifest] ignore = .editorconfig .meta.cfg +{% if with_docs %} docs/_build/html/_sources/* +{% endif %} +{% if with_sphinx_doctests %} docs/_build/doctest/* +{% endif %} diff --git a/config/default/tests.yml.j2 b/config/default/tests.yml.j2 index 5d0e378..0394b32 100644 --- a/config/default/tests.yml.j2 +++ b/config/default/tests.yml.j2 @@ -14,14 +14,18 @@ jobs: config: # [Python version, tox env] - ["3.8", "lint"] +{% if with_legacy_python %} - ["2.7", "py27"] - ["3.5", "py35"] +{% endif %} - ["3.6", "py36"] - ["3.7", "py37"] - ["3.8", "py38"] - ["3.9", "py39"] -{% if with_pypy %} +{% if with_pypy and with_legacy_python %} - ["pypy2", "pypy"] +{% endif %} +{% if with_pypy %} - ["pypy3", "pypy3"] {% endif %} {% if with_docs %} diff --git a/config/pure-python/packages.txt b/config/pure-python/packages.txt index 1ed77d9..07507e0 100644 --- a/config/pure-python/packages.txt +++ b/config/pure-python/packages.txt @@ -17,3 +17,4 @@ grokcore.component zc.relationship bobo megrok.strictrequire +importchecker diff --git a/config/pure-python/setup.cfg b/config/pure-python/setup.cfg deleted file mode 100644 index 4c17add..0000000 --- a/config/pure-python/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[bdist_wheel] -universal = 1 - -[flake8] -doctests = 1 - -[check-manifest] -ignore = - .editorconfig - .meta.cfg - docs/_build/html/_sources/* - docs/_build/doctest/* diff --git a/config/pure-python/tox.ini.j2 b/config/pure-python/tox.ini.j2 index 234453e..9e9d6ba 100644 --- a/config/pure-python/tox.ini.j2 +++ b/config/pure-python/tox.ini.j2 @@ -1,14 +1,18 @@ [tox] envlist = lint, +{% if with_legacy_python %} py27, py35, +{% endif %} py36, py37, py38, py39, -{% if with_pypy %} +{% if with_pypy and with_legacy_python %} pypy, +{% endif %} +{% if with_pypy %} pypy3, {% endif %} {% if with_docs %}