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 python<=3.7 support #769

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "pypy-3.9", "3.12"]
python-version: ["pypy-3.9", "3.12"]
runs-on: [ubuntu-latest, macos-13]
cmake-version: ["3.15.x"]

include:
- python-version: "3.7"
runs-on: windows-2022
cmake-version: "3.21.x"
- python-version: "pypy-3.8"
runs-on: windows-2022
cmake-version: "3.21.x"
- python-version: "3.11"
runs-on: windows-2022
cmake-version: "3.26.x"
- python-version: "pypy-3.7"
runs-on: ubuntu-latest
cmake-version: "3.15.x"
- python-version: "pypy-3.10"
runs-on: ubuntu-latest
cmake-version: "3.15.x"
Expand Down
8 changes: 2 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
from __future__ import annotations

import importlib
import importlib.metadata
import inspect
import os
import sys
import warnings
from pathlib import Path

if sys.version_info < (3, 8):
import importlib_metadata
else:
import importlib.metadata as importlib_metadata

try:
import scikit_build_core
except ModuleNotFoundError:
Expand All @@ -32,7 +28,7 @@
from scikit_build_core import __version__ as version
except ModuleNotFoundError:
try:
version = importlib_metadata.version("scikit_build_core")
version = importlib.metadata.version("scikit_build_core")
except ModuleNotFoundError:
msg = (
"Package should be installed to produce documentation! "
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,17 @@ known-local-folder = ["pathutils"]
"typing.Mapping".msg = "Use collections.abc.Mapping instead."
"typing.Sequence".msg = "Use collections.abc.Sequence instead."
"typing.Set".msg = "Use collections.abc.Set instead."
"typing.Literal".msg = "Use scikit_build_core._compat.typing.Literal instead."
"typing.Protocol".msg = "Use scikit_build_core._compat.typing.Protocol instead."
"typing.Self".msg = "Use scikit_build_core._compat.typing.Self instead."
"typing_extensions.Self".msg = "Use scikit_build_core._compat.typing.Self instead."
"typing.runtime_checkable".msg = "Add and use scikit_build_core._compat.typing.runtime_checkable instead."
"typing.Final".msg = "Add scikit_build_core._compat.typing.Final instead."
"typing.NotRequired".msg = "Add scikit_build_core._compat.typing.NotRequired instead."
"typing.OrderedDict".msg = "Add scikit_build_core._compat.typing.OrderedDict instead."
"typing.TypedDict".msg = "Add scikit_build_core._compat.typing.TypedDict instead."
"typing.assert_never".msg = "Add scikit_build_core._compat.typing.assert_never instead."
"tomli".msg = "Use scikit_build_core._compat.tomllib instead."
"tomllib".msg = "Use scikit_build_core._compat.tomllib instead."
"importlib.metadata".msg = "Use scikit_build_core._compat.importlib.metadata instead."
"importlib_metadata".msg = "Use scikit_build_core._compat.importlib.metadata instead."
"importlib_metadata".msg = "Use importlib.metadata directly instead."
"importlib.metadata.entry_points".msg = "Use scikit_build_core._compat.importlib.metadata.entry_points instead."
"importlib.resources".msg = "Use scikit_build_core._compat.importlib.resources instead."
"importlib_resources".msg = "Use scikit_build_core._compat.importlib.resources instead."
"pyproject_metadata".msg = "Use scikit_build_core._vendor.pyproject_metadata instead."
Expand Down
23 changes: 5 additions & 18 deletions src/scikit_build_core/_compat/importlib/metadata.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
from __future__ import annotations

import importlib.metadata
import sys
import typing

if sys.version_info < (3, 8):
import importlib_metadata as _metadata
from importlib_metadata import PathDistribution, version
else:
import importlib.metadata as _metadata
from importlib.metadata import PathDistribution, version


if typing.TYPE_CHECKING:
if sys.version_info < (3, 8):
from importlib_metadata import EntryPoints
elif sys.version_info < (3, 10):
if sys.version_info < (3, 10):
from importlib.metadata import EntryPoint

EntryPoints = typing.List[EntryPoint]
else:
from importlib.metadata import EntryPoints

__all__ = ["entry_points", "PathDistribution", "version"]
__all__ = ["entry_points"]


def entry_points(*, group: str) -> EntryPoints:
if sys.version_info >= (3, 10):
return _metadata.entry_points(group=group)

epg = _metadata.entry_points()

if sys.version_info < (3, 8) and hasattr(epg, "select"):
return epg.select(group=group) # type: ignore[no-any-return, no-untyped-call]
return importlib.metadata.entry_points(group=group)

epg = importlib.metadata.entry_points()
return epg.get(group, [])


Expand Down
10 changes: 0 additions & 10 deletions src/scikit_build_core/_compat/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
import sys
import typing

if sys.version_info < (3, 8):
from typing_extensions import (
Literal,
Protocol,
)
else:
from typing import Literal, Protocol

if sys.version_info < (3, 9):
from typing_extensions import Annotated, get_args, get_origin
else:
Expand All @@ -31,8 +23,6 @@ def assert_never(_: object) -> None:

__all__ = [
"Annotated",
"Literal",
"Protocol",
"Self",
"assert_never",
"get_args",
Expand Down
21 changes: 7 additions & 14 deletions src/scikit_build_core/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import re
import sys
from typing import Any

__all__ = ["ScikitBuildLogger", "logger", "raw_logger", "rich_print", "LEVEL_VALUE"]

Expand Down Expand Up @@ -44,37 +43,31 @@
)


if sys.version_info < (3, 8):
opts: Any = {}
else:
opts: Any = {"stacklevel": 2}


class ScikitBuildLogger:
# pylint: disable-next=redefined-outer-name
def __init__(self, logger: logging.Logger) -> None:
self.logger = logger

def debug(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.debug(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.debug(FStringMessage(msg, *args, **kwargs), stacklevel=2)

def info(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.info(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.info(FStringMessage(msg, *args, **kwargs), stacklevel=2)

def warning(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.warning(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.warning(FStringMessage(msg, *args, **kwargs), stacklevel=2)

def error(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.error(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.error(FStringMessage(msg, *args, **kwargs), stacklevel=2)

Check warning on line 61 in src/scikit_build_core/_logging.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/_logging.py#L61

Added line #L61 was not covered by tests

def critical(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.critical(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.critical(FStringMessage(msg, *args, **kwargs), stacklevel=2)

Check warning on line 64 in src/scikit_build_core/_logging.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/_logging.py#L64

Added line #L64 was not covered by tests

def exception(self, msg: str, *args: object, **kwargs: object) -> None:
self.logger.exception(FStringMessage(msg, *args, **kwargs), **opts)
self.logger.exception(FStringMessage(msg, *args, **kwargs), stacklevel=2)

Check warning on line 67 in src/scikit_build_core/_logging.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/_logging.py#L67

Added line #L67 was not covered by tests

def log(self, level: int, msg: str, *args: object, **kwargs: object) -> None:
self.logger.log(level, FStringMessage(msg, *args, **kwargs), **opts)
self.logger.log(level, FStringMessage(msg, *args, **kwargs), stacklevel=2)

Check warning on line 70 in src/scikit_build_core/_logging.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/_logging.py#L70

Added line #L70 was not covered by tests

def setLevel(self, level: int) -> None: # noqa: N802
self.logger.setLevel(level)
Expand Down
4 changes: 2 additions & 2 deletions src/scikit_build_core/build/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import sysconfig
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

from .. import __version__
from .._compat import tomllib
from .._compat.typing import Literal, assert_never
from .._compat.typing import assert_never
from .._logging import logger, rich_print
from .._shutil import fix_win_37_all_permissions
from ..builder.builder import Builder, archs_to_tags, get_archs
Expand Down
4 changes: 2 additions & 2 deletions src/scikit_build_core/builder/get_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import importlib.util
import os
import sysconfig
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

from packaging.tags import sys_tags

Expand All @@ -24,7 +24,7 @@
if TYPE_CHECKING:
from collections.abc import Generator, Mapping

from .._compat.typing import Literal, Self
from .._compat.typing import Self

Check warning on line 27 in src/scikit_build_core/builder/get_requires.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/builder/get_requires.py#L27

Added line #L27 was not covered by tests
from ..settings.skbuild_model import ScikitBuildSettings

__all__ = ["GetRequires"]
Expand Down
15 changes: 1 addition & 14 deletions src/scikit_build_core/builder/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ def get_host_platform() -> str:
Return a string that identifies the current platform. This mimics
setuptools get_host_platform (without 3.8 aix compat).
"""

if sys.version_info < (3, 8) and os.name == "nt":
if "(arm)" in sys.version.lower():
return "win-arm32"
if "(arm64)" in sys.version.lower():
return "win-arm64"

return sysconfig.get_platform()


Expand Down Expand Up @@ -163,13 +156,7 @@ def get_soabi(env: Mapping[str, str], *, abi3: bool = False) -> str:
if setuptools_ext_suffix:
return setuptools_ext_suffix.rsplit(".", 1)[0].lstrip(".")

if sys.version_info < (3, 8, 7):
# See https://github.com/python/cpython/issues/84006
import distutils.sysconfig # pylint: disable=deprecated-module

ext_suffix = distutils.sysconfig.get_config_var("EXT_SUFFIX")
else:
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")

assert isinstance(ext_suffix, str)
return ext_suffix.rsplit(".", 1)[0].lstrip(".")
Expand Down
7 changes: 3 additions & 4 deletions src/scikit_build_core/hatch/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
from __future__ import annotations

import copy
import importlib.metadata
import os
import shutil
import sys
import sysconfig
import tempfile
import typing
from pathlib import Path
from typing import Any
from typing import Any, Literal

from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from packaging.version import Version

from scikit_build_core.settings.skbuild_model import ScikitBuildSettings

from .. import __version__
from .._compat.importlib.metadata import version as pkg_version
from .._compat.typing import Literal
from .._logging import logger, rich_print
from ..build._init import setup_logging
from ..builder.builder import Builder, archs_to_tags, get_archs
Expand Down Expand Up @@ -220,7 +219,7 @@
f"SKBUILD_{k.upper()}_DIR": v for k, v in wheel_dirs.items()
}
cache_entries["SKBUILD_STATE"] = state
cache_entries["SKBUILD_HATCHLING"] = pkg_version("hatchling")
cache_entries["SKBUILD_HATCHLING"] = importlib.metadata.version("hatchling")

Check warning on line 222 in src/scikit_build_core/hatch/plugin.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/hatch/plugin.py#L222

Added line #L222 was not covered by tests
builder.configure(
defines=defines,
cache_entries=cache_entries,
Expand Down
4 changes: 1 addition & 3 deletions src/scikit_build_core/settings/_load_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import importlib
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any, Union

from .._compat.typing import Protocol
from typing import TYPE_CHECKING, Any, Protocol, Union

if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Mapping
Expand Down
5 changes: 0 additions & 5 deletions src/scikit_build_core/settings/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ast
import dataclasses
import inspect
import sys
import textwrap
from pathlib import Path
from typing import TYPE_CHECKING
Expand All @@ -24,10 +23,6 @@ def __dir__() -> list[str]:


def _get_value(value: ast.expr) -> str:
if sys.version_info < (3, 8):
assert isinstance(value, ast.Str)
return value.s

assert isinstance(value, ast.Constant)
assert isinstance(value.value, str)
return value.value
Expand Down
4 changes: 2 additions & 2 deletions src/scikit_build_core/settings/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import dataclasses
import sys
from pathlib import Path
from typing import Any, Union
from typing import Any, Literal, Union

from packaging.specifiers import SpecifierSet
from packaging.version import Version

from .._compat.builtins import ExceptionGroup
from .._compat.typing import Annotated, Literal, get_args, get_origin
from .._compat.typing import Annotated, get_args, get_origin
from .documentation import pull_docs

__all__ = ["FailedConversionError", "convert_type", "to_json_schema"]
Expand Down
4 changes: 2 additions & 2 deletions src/scikit_build_core/settings/skbuild_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import dataclasses
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Literal, Optional, Union

from packaging.specifiers import SpecifierSet
from packaging.version import Version

from .._compat.typing import Annotated, Literal
from .._compat.typing import Annotated

__all__ = [
"BackportSettings",
Expand Down
3 changes: 1 addition & 2 deletions src/scikit_build_core/settings/skbuild_read_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

from packaging.specifiers import SpecifierSet
from packaging.version import Version
Expand All @@ -23,7 +23,6 @@
if TYPE_CHECKING:
from collections.abc import Generator, Mapping

from .._compat.typing import Literal

__all__ = ["SettingsReader"]

Expand Down
4 changes: 2 additions & 2 deletions src/scikit_build_core/settings/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
import dataclasses
import os
import typing
from typing import Any, TypeVar, Union
from typing import Any, Literal, Protocol, TypeVar, Union

from .._compat.builtins import ExceptionGroup
from .._compat.typing import Annotated, Literal, Protocol, get_args, get_origin
from .._compat.typing import Annotated, get_args, get_origin

if typing.TYPE_CHECKING:
from collections.abc import Generator, Iterator, Mapping, Sequence
Expand Down
3 changes: 1 addition & 2 deletions src/scikit_build_core/setuptools/build_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import shutil
import sys
from pathlib import Path
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING, ClassVar, Literal

import setuptools
import setuptools.errors
Expand All @@ -18,7 +18,6 @@
if TYPE_CHECKING:
from setuptools.dist import Distribution

from .._compat.typing import Literal
from ..settings.skbuild_model import ScikitBuildSettings

__all__ = [
Expand Down
Loading
Loading