Skip to content

Commit

Permalink
maintenance: drop support for EOL Python 3.8
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
stanislavlevin committed Nov 7, 2024
1 parent 9ff87d6 commit 4ee6ff2
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 70 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
7 changes: 4 additions & 3 deletions backend/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ def package_record(self):
zinfo.compress_type = ZIP_DEFLATED

self.records.append((str(dist_info_record), "", ""))
with self._zipfile.open(zinfo, "w") as f, TextIOWrapper(
f, encoding="utf-8", newline=""
) as csvf:
with (
self._zipfile.open(zinfo, "w") as f,
TextIOWrapper(f, encoding="utf-8", newline="") as csvf,
):
writer = csv.writer(csvf, lineterminator="\n")
writer.writerows(self.records)

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pyproject-installer"
description = "Pyproject installer"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = {text = "MIT"}
authors = [
{name = "Stanislav Levin", email = "[email protected]"},
Expand All @@ -15,7 +15,6 @@ classifiers = [
"Operating System :: Unix",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
38 changes: 18 additions & 20 deletions src/pyproject_installer/build_cmd/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,39 +116,37 @@ def build_metadata(srcdir, outdir, config=None, verbose=False):

hook = "prepare_metadata_for_build_wheel"
logger.info("Building metadata with %s", hook)
with build_out_tmpdir(srcdir, hook, config, verbose) as (
distinfo_dir,
tmp_path,
with (
build_out_tmpdir(srcdir, hook, config, verbose) as (
distinfo_dir,
tmp_path,
),
):
if distinfo_dir:
metadata_path_src = tmp_path / distinfo_dir / metadata_filename
# Python 3.8 syntax
with metadata_path_src.open(
mode="rb"
) as fsrc, metadata_path_dest.open(mode="wb") as fdst:
with (
metadata_path_src.open(mode="rb") as fsrc,
metadata_path_dest.open(mode="wb") as fdst,
):
shutil.copyfileobj(fsrc, fdst)
return metadata_filename

# backend doesn't support optional prepare_metadata_for_build_wheel
# fallback to build_wheel
hook = "build_wheel"
logger.info("Fallback to building metadata with %s", hook)
with build_out_tmpdir(srcdir, hook, config, verbose) as (
wheel_filename,
tmp_path,
with (
build_out_tmpdir(srcdir, hook, config, verbose) as (
wheel_filename,
tmp_path,
),
):
wheel_path = tmp_path / wheel_filename
with WheelFile(wheel_path) as whl:
metadata_path_src = whl.dist_info / metadata_filename
if sys.version_info > (3, 9):
# Python3.9: zipfile.Path.open opens in text mode by default
mode = "rb"
else:
# Python3.8: zipfile.Path.open supports only binary mode
mode = "r"
# Python 3.8 syntax
with metadata_path_src.open(
mode=mode
) as fsrc, metadata_path_dest.open(mode="wb") as fdst:
with (
metadata_path_src.open(mode="rb") as fsrc,
metadata_path_dest.open(mode="wb") as fdst,
):
shutil.copyfileobj(fsrc, fdst)
return metadata_filename
17 changes: 1 addition & 16 deletions src/pyproject_installer/lib/entry_points.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
def parse_entry_points(distr, group):
"""
Compat only.
- module and attr attributes of ep are available since Python 3.9
- "selectable" entry points were introduced in Python 3.10
"""
distr_eps = distr.entry_points
Expand All @@ -13,18 +12,4 @@ def parse_entry_points(distr, group):
else:
eps = distr_eps.select(group=group)

for ep in eps:
try:
# module is available since Python 3.9
ep_module = ep.module
except AttributeError:
ep_match = ep.pattern.match(ep.value)
ep_module = ep_match.group("module")

try:
# attr is available since Python 3.9
ep_attr = ep.attr
except AttributeError:
ep_attr = ep_match.group("attr")

yield (ep.name, ep.value, ep_module, ep_attr)
yield from ((ep.name, ep.value, ep.module, ep.attr) for ep in eps)
15 changes: 4 additions & 11 deletions src/pyproject_installer/lib/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import csv
import hashlib
import logging
import sys

from ..errors import WheelFileError
from .entry_points import parse_entry_points
Expand Down Expand Up @@ -151,16 +150,10 @@ def validate_record(self):
record_path = self.dist_info / "RECORD"
recorded_files = set()

if sys.version_info > (3, 9):
# since Python3.9 zipfile.Path.open opens in text mode by default
mode = "rb"
else:
# while Python3.8 zipfile.Path.open supports only binary mode
mode = "r"

with record_path.open(mode=mode) as csvbf, TextIOWrapper(
csvbf, encoding="utf-8", newline=""
) as csvf:
with (
record_path.open(mode="rb") as csvbf,
TextIOWrapper(csvbf, encoding="utf-8", newline="") as csvf,
):
reader = csv.reader(csvf)
for row in reader:
# path, hash and size
Expand Down
8 changes: 1 addition & 7 deletions src/pyproject_installer/run_cmd/_run_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ def __init__(self, wheel):
"clear": True,
"upgrade": False,
"with_pip": False,
"upgrade_deps": False,
}
if sys.version_info > (3, 9):
# New in version 3.9: Added the upgrade_deps parameter
venv_kwargs["upgrade_deps"] = False
super().__init__(**venv_kwargs)

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

def install_console_scripts(self, context):
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def update_record(self):
self.record = ws.getvalue()

def drop_from_record(self, file):
with StringIO(self.record, newline="") as rs, StringIO(
newline=""
) as ws:
with (
StringIO(self.record, newline="") as rs,
StringIO(newline="") as ws,
):
reader = csv.reader(rs)
writer = csv.writer(ws, lineterminator="\n")
for row in reader:
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ def __init__(self, *args, **kwargs):
def ensure_directories(self, *args, **kwargs):
# save context for reusage
self.context = super().ensure_directories(*args, **kwargs)
# env_exec_cmd requires Python3.9+ (https://bugs.python.org/issue45337),
# for non-windows systems: context.env_exec_cmd = context.env_exe
if not hasattr(self.context, "env_exec_cmd"):
self.context.env_exec_cmd = self.context.env_exe
return self.context


Expand Down

0 comments on commit 4ee6ff2

Please sign in to comment.