Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to drop Python 2 support. #45

Merged
merged 3 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand All @@ -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
+++++++

Expand All @@ -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
Expand All @@ -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

icemac marked this conversation as resolved.
Show resolved Hide resolved
with-docs
Build the documentation via Sphinx: True/False

Expand All @@ -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
-----

Expand Down
6 changes: 5 additions & 1 deletion config/buildout-recipe/tox.ini.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
25 changes: 22 additions & 3 deletions config/config-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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',
Expand Down Expand Up @@ -118,14 +126,23 @@ 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(
'with-sphinx-doctests', False) or args.with_sphinx_doctests
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'
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
6 changes: 5 additions & 1 deletion config/default/tests.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
1 change: 1 addition & 0 deletions config/pure-python/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ grokcore.component
zc.relationship
bobo
megrok.strictrequire
importchecker
12 changes: 0 additions & 12 deletions config/pure-python/setup.cfg

This file was deleted.

6 changes: 5 additions & 1 deletion config/pure-python/tox.ini.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down