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

Drop support for Python 3.7. #153

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
25 changes: 12 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,22 @@ jobs:
fail-fast: false
matrix:
os:
- ["ubuntu", "ubuntu-20.04"]
- ["macos", "macos-11"]
- ["ubuntu", "ubuntu-latest"]
- ["macos", "macos-latest"]
config:
# [Python version, tox env]
- ["3.9", "release-check"]
- ["3.9", "lint"]
- ["3.7", "py37"]
- ["3.11", "release-check"]
- ["3.11", "lint"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.9", "coverage"]
- ["3.11", "coverage"]
exclude:
- { os: ["macos", "macos-11"], config: ["3.9", "release-check"] }
- { os: ["macos", "macos-11"], config: ["3.9", "lint"] }
- { os: ["macos", "macos-11"], config: ["3.9", "coverage"] }
# macOS/Python 3.11+ is set up for universal2 architecture
# which causes build and package selection issues.
- { os: ["macos", "macos-11"], config: ["3.11", "py311"] }
- { os: ["macos", "macos-11"], config: ["3.12", "py312"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "release-check"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "lint"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "coverage"] }

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand All @@ -61,7 +56,11 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Test
if: ${{ !startsWith(runner.os, 'Mac') }}
run: tox -e ${{ matrix.config[1] }}
- name: Test (macOS)
if: ${{ startsWith(runner.os, 'Mac') }}
run: tox -e ${{ matrix.config[1] }}-universal2
dataflake marked this conversation as resolved.
Show resolved Hide resolved
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
Expand Down
3 changes: 2 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[meta]
template = "zope-product"
commit-id = "1351c95d"
commit-id = "c412f00f"

[python]
with-pypy = false
with-sphinx-doctests = false
with-windows = false
with-future-python = false
with-macos = true
with-docs = false

[coverage]
fail-under = 85
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
7.2 (unreleased)
----------------

- Nothing changed yet.
- Drop support for Python 3.7.


7.1 (2024-03-21)
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -54,7 +53,7 @@
"Topic :: Internet :: WWW/HTTP :: Indexing/Search",
],
keywords='Zope catalog index search data',
python_requires='>=3.7',
python_requires='>=3.8',
install_requires=[
'setuptools',
'AccessControl >= 4.0a4',
Expand Down
4 changes: 2 additions & 2 deletions src/Products/ZCTextIndex/WidCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _encode(w):
b, c = divmod(w, 0x80)
a, b = divmod(b, 0x80)
s = chr(b) + chr(c)
if a < 0x80: # no more than 21 data bits
if a < 0x80: # no more than 21 data bits
return chr(a + 0x80) + s
a, b = divmod(a, 0x80)
assert a < 0x80, (w, a, b, s) # else more than 28 data bits
Expand All @@ -86,7 +86,7 @@ def _encode(w):


def decode(code):
# Handle bytes that were not properly decoded during Python 3 conversion
# Handle bytes that were not properly decoded during Python-3-conversion
if isinstance(code, bytes):
code = code.decode('latin1')
# Decode a string into a list of wids.
Expand Down
36 changes: 17 additions & 19 deletions src/Products/ZCatalog/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def load_default(cls):
try:
pmap = resolve(location)
cls.load_pmap(location, pmap)
except ImportError:
except ModuleNotFoundError:
logger.warning(f'could not load priority map from {location}')

@classmethod
Expand All @@ -121,8 +121,7 @@ def load_from_path(cls, path):

@classmethod
def load_pmap(cls, location, pmap):
logger.info('loaded priority %d map(s) from %s',
len(pmap), location)
logger.info('loaded priority %d map(s) from %s', len(pmap), location)
# Convert the simple benchmark tuples to namedtuples
new_plan = {}
for cid, plan in pmap.items():
Expand Down Expand Up @@ -251,8 +250,7 @@ def make_key(self, query):
key = [name for name in key if name not in notkeys]
key.extend([(name, "not") for name in notkeys])
# Workaround: Python only sorts on identical types.
tuple_keys = set(key) - {
x for x in key if not isinstance(x, tuple)}
tuple_keys = set(key) - {x for x in key if not isinstance(x, tuple)}

str_keys = set(key) - tuple_keys
return tuple(sorted(str_keys)) + tuple(sorted(tuple_keys))
Expand All @@ -264,9 +262,9 @@ def plan(self):

# sort indexes on (limited result index, mean search time)
# skip internal ('#') bookkeeping records
ranking = sorted(
[((value.limit, value.duration), name)
for name, value in benchmark.items() if '#' not in name])
ranking = sorted([((value.limit, value.duration), name)
for name, value in benchmark.items()
if '#' not in name])
return [r[1] for r in ranking]

def start(self):
Expand All @@ -281,8 +279,7 @@ def stop_split(self, name, result=None, limit=False):
start_time, stop_time = self.interim.get(name, Duration(None, None))
self.interim[name] = Duration(start_time, current)
dt = current - start_time
self.res.append(IndexMeasurement(
name=name, duration=dt, limit=limit))
self.res.append(IndexMeasurement(name=name, duration=dt, limit=limit))

if name.startswith('sort_on'):
# sort_on isn't an index. We only do time reporting on it
Expand All @@ -291,8 +288,7 @@ def stop_split(self, name, result=None, limit=False):
# remember index's hits, search time and calls
benchmark = self.benchmark
if name not in benchmark:
benchmark[name] = Benchmark(duration=dt,
hits=1, limit=limit)
benchmark[name] = Benchmark(duration=dt, hits=1, limit=limit)
else:
duration, hits, limit = benchmark[name]
duration = ((duration * hits) + dt) / float(hits + 1)
Expand All @@ -316,8 +312,7 @@ def stop(self):
if key in self.catalog.indexes:
index = self.catalog.indexes[key]
self.benchmark[key] = Benchmark(
0, 0, ILimitedResultIndex.providedBy(index)
)
0, 0, ILimitedResultIndex.providedBy(index))
else:
self.benchmark[key] = Benchmark(0, 0, False)
PriorityMap.set_entry(self.cid, self.key, self.benchmark)
Expand Down Expand Up @@ -354,11 +349,14 @@ def report(self):
'query': key,
'counter': report.hits,
'duration': report.duration * 1000,
'last': {'duration': last.duration * 1000,
'details': [dict(id=d.name,
duration=d.duration * 1000)
for d in last.details],
},
'last': {
'duration':
last.duration * 1000,
'details': [
dict(id=d.name, duration=d.duration * 1000)
for d in last.details
],
},
}
rval.append(info)

Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ minversion = 3.18
envlist =
release-check
lint
py37
py38
py39
py310
Expand All @@ -16,6 +15,7 @@ envlist =
[testenv]
skip_install = true
deps =
setuptools < 69
zc.buildout >= 3.0.1
wheel > 0.37
setenv =
Expand All @@ -25,6 +25,7 @@ commands_pre =
{envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test
commands =
{envbindir}/test {posargs:-cv}

[testenv:release-check]
description = ensure that the distribution is ready to release
basepython = python3
Expand Down Expand Up @@ -88,6 +89,7 @@ source = Products.ZCatalog

[coverage:report]
precision = 2
ignore_errors = True
exclude_lines =
pragma: no cover
pragma: nocover
Expand Down
Loading