Skip to content

Commit

Permalink
Drops support for installing rez-pip with Python 3.8 (#120)
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso authored Jan 18, 2025
1 parent ce91594 commit 2928d20
Show file tree
Hide file tree
Showing 33 changed files with 231 additions and 250 deletions.
9 changes: 8 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
branch = True
source_pkgs=rez_pip

[paths]
; Map files to src/ so that codecov is happy and can find the right paths.
source =
src
.nox/**/site-packages

[report]
exclude_also =
def __dir__
if TYPE_CHECKING:
if typing.TYPE_CHECKING:
if typing\.TYPE_CHECKING:
\.\.\.
11 changes: 1 addition & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ jobs:
# Ping macos to 13 so that we get intel CPUs.
# TODO: Make our tests support arm64.
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
include:
# 3.7 is not available on Apple silicon.
# So manually add 3.7+macos13 and 3.7 on the other platforms.
# Note: The macos-13 image is the last macos image version on GHA to run on Intel CPUs.
- python: '3.7'
os: 'macos-13'
- python: '3.7'
os: 'windows-latest'
- python: '3.7'
os: 'ubuntu-latest'
fail-fast: false

steps:
Expand All @@ -56,6 +46,7 @@ jobs:
uses: codecov/codecov-action@v5
with:
files: 'coverage.xml'
disable_search: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
13 changes: 2 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder

linkcheck_allowed_redirects = {
r"https://github.com/JeanChristopheMorinPerso/rez-pip/issues/\d+": "https://github.com/JeanChristopheMorinPerso/rez-pip/pull/\d+"
r"https://github.com/JeanChristopheMorinPerso/rez-pip/issues/\d+": r"https://github.com/JeanChristopheMorinPerso/rez-pip/pull/\d+"
}


Expand Down Expand Up @@ -214,7 +214,7 @@ def run(self) -> list[docutils.nodes.Node]:

# Add links to rez docs for known settings.
help_str = re.sub(
"(.* \(default: configured )([a-zA-Z_]+)(.*)$",
r"(.* \(default: configured )([a-zA-Z_]+)(.*)$",
r"\g<1> :external:data:`\g<2>`\g<3>",
help_str,
)
Expand Down Expand Up @@ -359,15 +359,6 @@ def autodoc_process_signature(
signature: str,
return_annotation,
):
for name in ["Sequence", "Mapping", "MutableSequence"]:
signature = signature.replace(
f"rez_pip.compat.{name}", f"~collections.abc.{name}"
)
if return_annotation:
return_annotation = return_annotation.replace(
f"rez_pip.compat.{name}", f"~collections.abc.{name}"
)

signature = signature.replace(
"rez_pip.compat.importlib_metadata", "~importlib.metadata"
)
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
files = src
python_version = 3.7
python_version = 3.8
strict = True
show_error_codes = True
warn_unused_configs = True
Expand Down
5 changes: 2 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def lint(session: nox.Session):

@nox.session()
def mypy(session: nox.Session):
session.install("mypy")
session.install(".", "-c", "tests/constraints.txt")
session.install("mypy", ".")

session.run("mypy")

Expand All @@ -26,7 +25,7 @@ def format(session: nox.Session):
session.run("black", ".", "--check")


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
def test(session: nox.Session):
session.install("-r", "tests/requirements.txt")
session.install(".")
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
]
license = { file="LICENSE" }
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = [
"installer>=0.7.0",
"aiohttp",
Expand All @@ -20,10 +20,9 @@ dependencies = [
"rez>=2.114.1",
"dataclasses-json",
"rich",
"importlib_metadata>=4.6 ; python_version < '3.10'",
"importlib_metadata>=4.6; python_version < '3.10'",
# 1.3 introduces type hints.
"pluggy>=1.2",
"typing-extensions; python_version < '3.8'",
# Patches are finicky... Let's lock on the current latest version.
# We could always relax later if needed.
"patch-ng==1.18.1",
Expand All @@ -33,7 +32,6 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"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 Down
16 changes: 8 additions & 8 deletions scripts/get_pyside6_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def __init__(
self._length = int(head.headers["Content-Length"])
self._file = tempfile.NamedTemporaryFile()
self.truncate(self._length)
self._left: typing.List[int] = []
self._right: typing.List[int] = []
self._left: list[int] = []
self._right: list[int] = []
if "bytes" not in head.headers.get("Accept-Ranges", "none"):
raise ValueError("range request is not supported")
self._check_zip()
Expand Down Expand Up @@ -101,7 +101,7 @@ def tell(self) -> int:
"""Return the current position."""
return self._file.tell()

def truncate(self, size: typing.Optional[int] = None) -> int:
def truncate(self, size: int | None = None) -> int:
"""Resize the stream to the given size in bytes.
If size is unspecified resize to the current position.
Expand All @@ -115,15 +115,15 @@ def writable(self) -> bool:
"""Return False."""
return False

def __enter__(self) -> "LazyZipOverHTTP":
def __enter__(self) -> LazyZipOverHTTP:
self._file.__enter__()
return self

def __exit__(self, *exc: Any) -> None:
self._file.__exit__(*exc)

@contextlib.contextmanager
def _stay(self) -> typing.Generator[None, None, None]:
def _stay(self) -> typing.Generator[None]:
"""Return a context manager keeping the position.
At the end of the block, seek back to original position.
Expand Down Expand Up @@ -153,7 +153,7 @@ def _stream_response(
self,
start: int,
end: int,
base_headers: typing.Dict[str, str] = {"Accept-Encoding": "identity"},
base_headers: dict[str, str] = {"Accept-Encoding": "identity"},
) -> requests.Response:
"""Return HTTP response to a range request from start to end."""
headers = base_headers.copy()
Expand All @@ -164,7 +164,7 @@ def _stream_response(

def _merge(
self, start: int, end: int, left: int, right: int
) -> typing.Generator[typing.Tuple[int, int], None, None]:
) -> typing.Generator[tuple[int, int]]:
"""Return a generator of intervals to be fetched.
Args:
Expand Down Expand Up @@ -276,7 +276,7 @@ def run():
while len(versions) > 1:
leftFile = f"patches/data/{versions[0]}/__init__.py"
rightFile = f"patches/data/{versions[1]}/__init__.py"
with open(leftFile, "r") as lfh, open(rightFile, "r") as rfh:
with open(leftFile) as lfh, open(rightFile) as rfh:
lhs = ast.parse(lfh.read())
rhs = ast.parse(rfh.read())

Expand Down
15 changes: 6 additions & 9 deletions src/rez_pip/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import sys
import json
import shutil
import typing
import logging
import argparse
import textwrap
Expand Down Expand Up @@ -35,7 +34,7 @@
__all__ = ["run"]


def __dir__() -> typing.List[str]:
def __dir__() -> list[str]:
return __all__


Expand Down Expand Up @@ -134,8 +133,8 @@ def _createParser() -> argparse.ArgumentParser:


def _parseArgs(
args: typing.List[str],
) -> typing.Tuple[argparse.Namespace, typing.List[str]]:
args: list[str],
) -> tuple[argparse.Namespace, list[str]]:
parser = _createParser()

knownArgs = []
Expand Down Expand Up @@ -170,7 +169,7 @@ def _validateArgs(args: argparse.Namespace) -> None:
)


def _run(args: argparse.Namespace, pipArgs: typing.List[str], pipWorkArea: str) -> None:
def _run(args: argparse.Namespace, pipArgs: list[str], pipWorkArea: str) -> None:
pythonVersions = rez_pip.rez.getPythonExecutables(
args.python_version, packageFamily="python"
)
Expand Down Expand Up @@ -207,9 +206,7 @@ def _run(args: argparse.Namespace, pipArgs: typing.List[str], pipWorkArea: str)
)

_LOG.info(f"Resolved {len(packages)} dependencies for python {pythonVersion}")
_packageGroups: typing.List[
rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]
] = list(
_packageGroups: list[rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]] = list(
itertools.chain(*rez_pip.plugins.getHook().groupPackages(packages=packages)) # type: ignore[arg-type]
)

Expand All @@ -231,7 +228,7 @@ def _run(args: argparse.Namespace, pipArgs: typing.List[str], pipWorkArea: str)
# TODO: Should we postpone downloading to the last minute if we can?
_LOG.info("[bold]Downloading...")

packageGroups: typing.List[
packageGroups: list[
rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]
] = rez_pip.download.downloadPackages(_packageGroups, wheelsDir)

Expand Down
6 changes: 1 addition & 5 deletions src/rez_pip/compat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import sys

if sys.version_info <= (3, 8):
from typing import Sequence, MutableSequence, Mapping
else:
from collections.abc import Sequence, MutableSequence, Mapping

if sys.version_info >= (3, 10):
import importlib.metadata as importlib_metadata
else:
import importlib_metadata

__all__ = ["Sequence", "MutableSequence", "Mapping", "importlib_metadata"]
__all__ = ["importlib_metadata"]
14 changes: 7 additions & 7 deletions src/rez_pip/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@


def downloadPackages(
packageGroups: typing.List[rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]],
packageGroups: list[rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]],
dest: str,
) -> typing.List[rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]]:
) -> list[rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]]:
return asyncio.run(_downloadPackages(packageGroups, dest))


async def _downloadPackages(
packageGroups: typing.List[rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]],
packageGroups: list[rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo]],
dest: str,
) -> list[rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]]:
newPackageGroups: typing.List[
rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]
] = []
newPackageGroups: list[rez_pip.pip.PackageGroup[rez_pip.pip.DownloadedArtifact]] = (
[]
)
someFailed = False

async with aiohttp.ClientSession() as session:
Expand All @@ -43,7 +43,7 @@ async def _downloadPackages(
transient=True,
console=rez_pip.utils.CONSOLE,
) as progress:
tasks: typing.Dict[str, rich.progress.TaskID] = {}
tasks: dict[str, rich.progress.TaskID] = {}

# Create all the download tasks first
numPackages = 0
Expand Down
Loading

0 comments on commit 2928d20

Please sign in to comment.