Skip to content

Commit 0884211

Browse files
maintenance: drop support for EOL Python 3.8
According to Python life cycle: https://devguide.python.org/versions/ https://peps.python.org/pep-0569/ > As of 2024-10-07, 3.8 has reached the end-of-life phase of its release cycle. 3.8.20 was the final security release. The codebase for 3.8 is now frozen and no further updates will be provided nor issues of any kind will be accepted on the bug tracker. - require Python 3.9+ - cleaned up code for Python 3.8 support - run CI for Python 3.9+ Fixes: #83 Signed-off-by: Stanislav Levin <[email protected]>
1 parent 9ff87d6 commit 0884211

File tree

9 files changed

+36
-70
lines changed

9 files changed

+36
-70
lines changed

.github/workflows/pipelines.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ubuntu-latest
3434
strategy:
3535
matrix:
36-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
36+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
3737

3838
steps:
3939
- uses: actions/checkout@v4
@@ -63,7 +63,7 @@ jobs:
6363
runs-on: ubuntu-latest
6464
strategy:
6565
matrix:
66-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
66+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
6767

6868
steps:
6969
- uses: actions/checkout@v4
@@ -93,7 +93,7 @@ jobs:
9393
runs-on: ubuntu-latest
9494
strategy:
9595
matrix:
96-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
96+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
9797

9898
steps:
9999
- uses: actions/checkout@v4
@@ -122,7 +122,7 @@ jobs:
122122
runs-on: ubuntu-latest
123123
strategy:
124124
matrix:
125-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
125+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
126126
steps:
127127
- uses: actions/checkout@v4
128128
- uses: actions/setup-python@v5

backend/wheel.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ def package_record(self):
170170
zinfo.compress_type = ZIP_DEFLATED
171171

172172
self.records.append((str(dist_info_record), "", ""))
173-
with self._zipfile.open(zinfo, "w") as f, TextIOWrapper(
174-
f, encoding="utf-8", newline=""
175-
) as csvf:
173+
with (
174+
self._zipfile.open(zinfo, "w") as f,
175+
TextIOWrapper(f, encoding="utf-8", newline="") as csvf,
176+
):
176177
writer = csv.writer(csvf, lineterminator="\n")
177178
writer.writerows(self.records)
178179

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "pyproject-installer"
33
description = "Pyproject installer"
44
readme = "README.md"
5-
requires-python = ">=3.8"
5+
requires-python = ">=3.9"
66
license = {text = "MIT"}
77
authors = [
88
{name = "Stanislav Levin", email = "[email protected]"},
@@ -15,7 +15,6 @@ classifiers = [
1515
"Operating System :: Unix",
1616
"Programming Language :: Python :: 3",
1717
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.8",
1918
"Programming Language :: Python :: 3.9",
2019
"Programming Language :: Python :: 3.10",
2120
"Programming Language :: Python :: 3.11",

src/pyproject_installer/build_cmd/_build.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -116,39 +116,36 @@ def build_metadata(srcdir, outdir, config=None, verbose=False):
116116

117117
hook = "prepare_metadata_for_build_wheel"
118118
logger.info("Building metadata with %s", hook)
119-
with build_out_tmpdir(srcdir, hook, config, verbose) as (
120-
distinfo_dir,
121-
tmp_path,
119+
with (
120+
build_out_tmpdir(srcdir, hook, config, verbose) as (
121+
distinfo_dir, tmp_path,
122+
),
122123
):
123124
if distinfo_dir:
124125
metadata_path_src = tmp_path / distinfo_dir / metadata_filename
125-
# Python 3.8 syntax
126-
with metadata_path_src.open(
127-
mode="rb"
128-
) as fsrc, metadata_path_dest.open(mode="wb") as fdst:
126+
with (
127+
metadata_path_src.open(mode="rb") as fsrc,
128+
metadata_path_dest.open(mode="wb") as fdst,
129+
):
129130
shutil.copyfileobj(fsrc, fdst)
130131
return metadata_filename
131132

132133
# backend doesn't support optional prepare_metadata_for_build_wheel
133134
# fallback to build_wheel
134135
hook = "build_wheel"
135136
logger.info("Fallback to building metadata with %s", hook)
136-
with build_out_tmpdir(srcdir, hook, config, verbose) as (
137-
wheel_filename,
138-
tmp_path,
137+
with (
138+
build_out_tmpdir(srcdir, hook, config, verbose) as (
139+
wheel_filename,
140+
tmp_path,
141+
),
139142
):
140143
wheel_path = tmp_path / wheel_filename
141144
with WheelFile(wheel_path) as whl:
142145
metadata_path_src = whl.dist_info / metadata_filename
143-
if sys.version_info > (3, 9):
144-
# Python3.9: zipfile.Path.open opens in text mode by default
145-
mode = "rb"
146-
else:
147-
# Python3.8: zipfile.Path.open supports only binary mode
148-
mode = "r"
149-
# Python 3.8 syntax
150-
with metadata_path_src.open(
151-
mode=mode
152-
) as fsrc, metadata_path_dest.open(mode="wb") as fdst:
146+
with (
147+
metadata_path_src.open(mode="rb") as fsrc,
148+
metadata_path_dest.open(mode="wb") as fdst,
149+
):
153150
shutil.copyfileobj(fsrc, fdst)
154151
return metadata_filename
+1-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
def parse_entry_points(distr, group):
22
"""
33
Compat only.
4-
- module and attr attributes of ep are available since Python 3.9
54
- "selectable" entry points were introduced in Python 3.10
65
"""
76
distr_eps = distr.entry_points
@@ -13,18 +12,4 @@ def parse_entry_points(distr, group):
1312
else:
1413
eps = distr_eps.select(group=group)
1514

16-
for ep in eps:
17-
try:
18-
# module is available since Python 3.9
19-
ep_module = ep.module
20-
except AttributeError:
21-
ep_match = ep.pattern.match(ep.value)
22-
ep_module = ep_match.group("module")
23-
24-
try:
25-
# attr is available since Python 3.9
26-
ep_attr = ep.attr
27-
except AttributeError:
28-
ep_attr = ep_match.group("attr")
29-
30-
yield (ep.name, ep.value, ep_module, ep_attr)
15+
yield from ((ep.name, ep.value, ep.module, ep.attr) for ep in eps)

src/pyproject_installer/lib/wheel.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import csv
88
import hashlib
99
import logging
10-
import sys
1110

1211
from ..errors import WheelFileError
1312
from .entry_points import parse_entry_points
@@ -151,16 +150,10 @@ def validate_record(self):
151150
record_path = self.dist_info / "RECORD"
152151
recorded_files = set()
153152

154-
if sys.version_info > (3, 9):
155-
# since Python3.9 zipfile.Path.open opens in text mode by default
156-
mode = "rb"
157-
else:
158-
# while Python3.8 zipfile.Path.open supports only binary mode
159-
mode = "r"
160-
161-
with record_path.open(mode=mode) as csvbf, TextIOWrapper(
162-
csvbf, encoding="utf-8", newline=""
163-
) as csvf:
153+
with (
154+
record_path.open(mode="rb") as csvbf,
155+
TextIOWrapper(csvbf, encoding="utf-8", newline="") as csvf,
156+
):
164157
reader = csv.reader(csvf)
165158
for row in reader:
166159
# path, hash and size

src/pyproject_installer/run_cmd/_run_env.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,13 @@ def __init__(self, wheel):
3333
"clear": True,
3434
"upgrade": False,
3535
"with_pip": False,
36+
"upgrade_deps": False,
3637
}
37-
if sys.version_info > (3, 9):
38-
# New in version 3.9: Added the upgrade_deps parameter
39-
venv_kwargs["upgrade_deps"] = False
4038
super().__init__(**venv_kwargs)
4139

4240
def ensure_directories(self, *args, **kwargs):
4341
# save context for reusage
4442
self.context = super().ensure_directories(*args, **kwargs)
45-
# env_exec_cmd requires Python3.9+ (https://bugs.python.org/issue45337),
46-
# for non-windows systems: context.env_exec_cmd = context.env_exe
47-
if not hasattr(self.context, "env_exec_cmd"):
48-
self.context.env_exec_cmd = self.context.env_exe
4943
return self.context
5044

5145
def install_console_scripts(self, context):

tests/conftest.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ def update_record(self):
7575
self.record = ws.getvalue()
7676

7777
def drop_from_record(self, file):
78-
with StringIO(self.record, newline="") as rs, StringIO(
79-
newline=""
80-
) as ws:
78+
with (
79+
StringIO(self.record, newline="") as rs,
80+
StringIO(newline="") as ws,
81+
):
8182
reader = csv.reader(rs)
8283
writer = csv.writer(ws, lineterminator="\n")
8384
for row in reader:

tests/integration/conftest.py

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ def __init__(self, *args, **kwargs):
2121
def ensure_directories(self, *args, **kwargs):
2222
# save context for reusage
2323
self.context = super().ensure_directories(*args, **kwargs)
24-
# env_exec_cmd requires Python3.9+ (https://bugs.python.org/issue45337),
25-
# for non-windows systems: context.env_exec_cmd = context.env_exe
26-
if not hasattr(self.context, "env_exec_cmd"):
27-
self.context.env_exec_cmd = self.context.env_exe
2824
return self.context
2925

3026

0 commit comments

Comments
 (0)