Skip to content

Commit

Permalink
Merge branch 'master' into add-windows-to-github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac authored Mar 22, 2024
2 parents 68b91ae + f631b48 commit 6615968
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 208 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cache/pip
Expand All @@ -27,7 +27,7 @@ jobs:
restore-keys: |
lint-v1-
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -11,13 +11,13 @@ repos:
- id: debug-statements
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
language_version: python3
additional_dependencies: [flake8-typing-imports==1.14.0]
additional_dependencies: [flake8-typing-imports==1.15.0]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.1
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/timothycrosley/isort
Expand All @@ -38,7 +38,7 @@ repos:
additional_dependencies: [pygments, restructuredtext_lint]
# This can deal with sphinx directives
- repo: https://github.com/myint/rstcheck
rev: "v6.1.1"
rev: "v6.2.0"
hooks:
- id: rstcheck
args: [--ignore-messages, Duplicate implicit target.*]
1 change: 1 addition & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Zope Foundation and Contributors
44 changes: 44 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Zope Public License (ZPL) Version 2.1

A copyright notice accompanies this license document that identifies the
copyright holders.

This license has been certified as open source. It has also been designated as
GPL compatible by the Free Software Foundation (FSF).

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions in source code must retain the accompanying copyright
notice, this list of conditions, and the following disclaimer.

2. Redistributions in binary form must reproduce the accompanying copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Names of the copyright holders must not be used to endorse or promote
products derived from this software without prior written permission from the
copyright holders.

4. The right to distribute this software or to use it for any purpose does not
give you the right to use Servicemarks (sm) or Trademarks (tm) of the
copyright
holders. Use of them is covered by separate agreement with the copyright
holders.

5. If any files are modified, you must cause the modified files to carry
prominent notices stating that you changed the files and the date of any
change.

Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 9 additions & 2 deletions config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ updated. Example:
" src/foo/bar.py: E221 E222",
"extend-ignore = D203, W503",
]
additional-plugins = [
"mccabe",
]
additional-sources = "testproj foo bar.py"
[manifest]
Expand Down Expand Up @@ -303,8 +306,8 @@ updated. Example:
"- [\"3.8\", \"py38-slim\"]",
]
additional-exclude = [
"- { os: windows, config: [\"pypy-3.9\", \"pypy\"] }",
"- { os: macos, config: [\"pypy-3.9\", \"pypy\"] }",
"- { os: windows, config: [\"pypy-3.10\", \"pypy3\"] }",
"- { os: macos, config: [\"pypy-3.10\", \"pypy3\"] }",
]
steps-before-checkout = [
"- name: \"Set some Postgres settings\"",
Expand Down Expand Up @@ -522,6 +525,10 @@ additional-config
list of strings so the leading white spaces and comments are preserved when
writing the value to ``setup.cfg``.

additional-plugins
Some packages want to have additional flake8 plugins installed.
This option is a list of strings.

additional-sources
Sometimes not only ``src`` and ``setup.py`` contain Python code to be checked
by flake8. Additional files or directories can be configured here. This
Expand Down
8 changes: 4 additions & 4 deletions config/c-code/tests-cache.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
###
Expand All @@ -23,7 +23,7 @@
echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT

- name: pip cache (default)
uses: actions/cache@v3
uses: actions/cache@v4
if: ${{ !startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-default.outputs.dir }}
Expand All @@ -32,7 +32,7 @@
${{ runner.os }}-pip-

- name: pip cache (Windows)
uses: actions/cache@v3
uses: actions/cache@v4
if: ${{ startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-windows.outputs.dir }}
Expand Down
2 changes: 1 addition & 1 deletion config/c-code/tests-download.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

- name: Download %(package_name)s wheel
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: %(package_name)s-${{ runner.os }}-${{ matrix.python-version }}.whl
path: dist/
4 changes: 2 additions & 2 deletions config/c-code/tests-strategy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
matrix:
python-version:
{% if with_pypy %}
- "pypy-3.9"
- "pypy-3.10"
{% endif %}
- "3.7"
- "3.8"
Expand All @@ -24,7 +24,7 @@
{% endif %}
{% if with_pypy %}
- os: macos-11
python-version: "pypy-3.9"
python-version: "pypy-3.10"
{% endif %}
{% for line in gha_additional_exclude %}
%(line)s
Expand Down
28 changes: 24 additions & 4 deletions config/c-code/tests.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,21 @@ jobs:
steps:
{% include 'tests-cache.j2' %}

{% if with_future_python %}
- name: Install Build Dependencies (%(future_python_version)s)
if: matrix.python-version == '%(future_python_version)s'
run: |
pip install -U pip
pip install -U setuptools wheel twine
# cffi will probably have no public release until a Python 3.13 beta
# or even RC release, see https://github.com/python-cffi/cffi/issues/23
echo "cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58" > cffi_constraint.txt
PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install cffi
{% endif %}
- name: Install Build Dependencies
{% if with_future_python %}
if: matrix.python-version != '%(future_python_version)s'
{% endif %}
run: |
pip install -U pip
pip install -U setuptools wheel twine cffi
Expand Down Expand Up @@ -152,9 +166,12 @@ jobs:
if: matrix.python-version == '%(future_python_version)s'
run: |
# Install to collect dependencies into the (pip) cache.
# cffi will probably have no public release until a Python 3.13 beta
# or even RC release, see https://github.com/python-cffi/cffi/issues/23
echo "cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58" > cffi_constraint.txt
# Use "--pre" here because dependencies with support for this future
# Python release may only be available as pre-releases
pip install --pre .[test]
PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install --pre .[test]
{% endif %}
- name: Install %(package_name)s and dependencies
{% if with_future_python %}
Expand Down Expand Up @@ -182,7 +199,7 @@ jobs:
{% else %}
!startsWith(runner.os, 'Mac')
{% endif %}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
{% if kind == 'macOS arm64' %}
# The arm64 wheel is uploaded with a different name just so it can be
Expand Down Expand Up @@ -241,6 +258,9 @@ jobs:
if: ${{ startsWith(matrix.python-version, '%(future_python_version)s') }}
run: |
pip install -U wheel setuptools
# cffi will probably have no public release until a beta or even RC
# version of Python 3.13, see https://github.com/python-cffi/cffi/issues/23
echo 'cffi @ git+https://github.com/python-cffi/cffi.git@954cab4f889fb019a7f90df153ee1be501495f58 ; platform_python_implementation == "CPython"' > cffi_constraint.txt
# coverage has a wheel on PyPI for a future python version which is
# not ABI compatible with the current one, so build it from sdist:
pip install -U --no-binary :all: coverage
Expand All @@ -250,7 +270,7 @@ jobs:
unzip -n dist/%(package_name)s-*whl -d src
# Use "--pre" here because dependencies with support for this future
# Python release may only be available as pre-releases
pip install --pre -U -e .[test]
PIP_CONSTRAINT=$PWD/cffi_constraint.txt pip install --pre -U -e .[test]
{% endif %}
- name: Install %(package_name)s
{% if with_future_python %}
Expand Down Expand Up @@ -400,7 +420,7 @@ jobs:
bash .manylinux.sh

- name: Upload %(package_name)s wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: wheelhouse/*whl
name: manylinux_${{ matrix.image }}_wheels.zip
Expand Down
39 changes: 24 additions & 15 deletions config/config-package.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!/usr/bin/env python3
##############################################################################
#
# Copyright (c) 2019 Zope Foundation and Contributors.
#
# 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.
#
##############################################################################
from functools import cached_property
from shared.call import abort
from shared.call import call
from shared.git import get_branch_name
from shared.git import get_commit_id
from shared.git import git_branch
from shared.path import change_dir
from shared.toml_encoder import TomlArraySeparatorEncoderWithNewline
import argparse
import collections
import jinja2
import pathlib
import shutil
import toml
import tomlkit


META_HINT = """\
Expand All @@ -23,7 +34,7 @@
Generated from:
https://github.com/zopefoundation/meta/tree/master/config/{config_type}
--> """
FUTURE_PYTHON_VERSION = ""
FUTURE_PYTHON_VERSION = "3.13.0-alpha - 3.13.0"
DEFAULT = object()


Expand Down Expand Up @@ -55,13 +66,13 @@ def handle_command_line_arguments():
'--no-flake8',
dest='use_flake8',
action='store_false',
default=None,
default=True,
help='Do not include flake8 and isort in the linting configuration.')
parser.add_argument(
'--with-appveyor',
dest='with_appveyor',
action='store_true',
default=None,
default=False,
help='Activate running tests on AppVeyor, too, '
'if not already configured in .meta.toml.')
parser.add_argument(
Expand Down Expand Up @@ -99,7 +110,7 @@ def handle_command_line_arguments():
'--with-sphinx',
dest='with_docs',
action='store_true',
default=None,
default=False,
help='Activate building docs if not already configured in .meta.toml.')
parser.add_argument(
'--with-sphinx-doctests',
Expand Down Expand Up @@ -166,7 +177,8 @@ def _read_meta_configuration(self):
"""Read and update meta configuration"""
meta_toml_path = self.path / '.meta.toml'
if meta_toml_path.exists():
meta_cfg = toml.load(meta_toml_path)
with open(meta_toml_path, 'rb') as meta_f:
meta_cfg = tomlkit.load(meta_f)
meta_cfg = collections.defaultdict(dict, **meta_cfg)
else:
meta_cfg = collections.defaultdict(dict)
Expand Down Expand Up @@ -226,10 +238,7 @@ def with_pypy(self):

@cached_property
def with_future_python(self):
if FUTURE_PYTHON_VERSION:
return self._set_python_config_value('future-python')
else:
return False
return self._set_python_config_value('future-python')

@cached_property
def with_docs(self):
Expand Down Expand Up @@ -423,6 +432,8 @@ def tox(self):
coverage_setenv = self.tox_option('coverage-setenv')
coverage_run_additional_config = self.meta_cfg['coverage-run'].get(
'additional-config', [])
flake8_additional_plugins = self.meta_cfg['flake8'].get(
'additional-plugins', '')
flake8_additional_sources = self.meta_cfg['flake8'].get(
'additional-sources', '')
if flake8_additional_sources:
Expand Down Expand Up @@ -454,6 +465,7 @@ def tox(self):
coverage_setenv=coverage_setenv,
fail_under=self.fail_under,
flake8_additional_sources=flake8_additional_sources,
flake8_additional_plugins=flake8_additional_plugins,
isort_additional_sources=isort_additional_sources,
testenv_additional=testenv_additional,
testenv_additional_extras=testenv_additional_extras,
Expand Down Expand Up @@ -624,10 +636,7 @@ def configure(self):
with open('.meta.toml', 'w') as meta_f:
meta_f.write(META_HINT.format(config_type=self.config_type))
meta_f.write('\n')
toml.dump(
meta_cfg, meta_f,
TomlArraySeparatorEncoderWithNewline(
separator=',\n ', indent_first_line=True))
tomlkit.dump(meta_cfg, meta_f)

tox_path = shutil.which('tox') or (
pathlib.Path(cwd) / 'bin' / 'tox')
Expand Down
2 changes: 0 additions & 2 deletions config/default/setup.cfg.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[bdist_wheel]
universal = 0
{% if zest_releaser_options %}

[zest.releaser]
Expand Down
Loading

0 comments on commit 6615968

Please sign in to comment.