Skip to content

Commit 52572cc

Browse files
authored
Merge pull request #1479 from henryiii/henryiii/fix/py37
fix: Python 3.7 support
2 parents c6027e4 + aff6dd5 commit 52572cc

24 files changed

+94
-91
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
matrix:
4040
os: [ubuntu-20.04, windows-latest, macos-11]
4141
python_version: ['3.11']
42+
include:
43+
- os: ubuntu-22.04
44+
python_version: '3.7'
4245
timeout-minutes: 180
4346
steps:
4447
- uses: actions/checkout@v3

bin/update_pythons.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,21 @@
55
import copy
66
import difflib
77
import logging
8-
import sys
98
from collections.abc import Mapping, MutableMapping
109
from pathlib import Path
1110
from typing import Any, Union
1211

1312
import click
1413
import requests
1514
import rich
16-
17-
if sys.version_info >= (3, 11):
18-
import tomllib
19-
else:
20-
import tomli as tomllib
21-
2215
from packaging.specifiers import Specifier
2316
from packaging.version import Version
2417
from rich.logging import RichHandler
2518
from rich.syntax import Syntax
2619

20+
from cibuildwheel._compat import tomllib
21+
from cibuildwheel._compat.typing import Final, Literal, TypedDict
2722
from cibuildwheel.extra import dump_python_configurations
28-
from cibuildwheel.typing import Final, Literal, TypedDict
2923

3024
log = logging.getLogger("cibw")
3125

bin/update_virtualenv.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55
import difflib
66
import logging
77
import subprocess
8-
import sys
98
from dataclasses import dataclass
109
from pathlib import Path
1110

1211
import click
1312
import rich
14-
15-
if sys.version_info >= (3, 11):
16-
import tomllib
17-
else:
18-
import tomli as tomllib
19-
2013
from packaging.version import InvalidVersion, Version
2114
from rich.logging import RichHandler
2215
from rich.syntax import Syntax
2316

24-
from cibuildwheel.typing import Final
17+
from cibuildwheel._compat import tomllib
18+
from cibuildwheel._compat.typing import Final
2519

2620
log = logging.getLogger("cibw")
2721

cibuildwheel/__main__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@
1616
import cibuildwheel.macos
1717
import cibuildwheel.util
1818
import cibuildwheel.windows
19+
from cibuildwheel._compat.typing import Protocol, assert_never
1920
from cibuildwheel.architecture import Architecture, allowed_architectures_check
2021
from cibuildwheel.logger import log
2122
from cibuildwheel.options import CommandLineArguments, Options, compute_options
22-
from cibuildwheel.typing import (
23-
PLATFORMS,
24-
GenericPythonConfiguration,
25-
PlatformName,
26-
assert_never,
27-
)
23+
from cibuildwheel.typing import PLATFORMS, GenericPythonConfiguration, PlatformName
2824
from cibuildwheel.util import (
2925
CIBW_CACHE_PATH,
3026
BuildSelector,
@@ -244,7 +240,7 @@ def _compute_platform(args: CommandLineArguments) -> PlatformName:
244240
return _compute_platform_ci()
245241

246242

247-
class PlatformModule(typing.Protocol):
243+
class PlatformModule(Protocol):
248244
# note that as per PEP544, the self argument is ignored when the protocol
249245
# is applied to a module
250246
def get_python_configurations(

cibuildwheel/_compat/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from __future__ import annotations
File renamed without changes.

cibuildwheel/_compat/functools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
5+
if sys.version_info >= (3, 8):
6+
from functools import cached_property
7+
else:
8+
from ._functools_cached_property_38 import cached_property
9+
10+
__all__ = ("cached_property",)

cibuildwheel/_compat/tomllib.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
5+
if sys.version_info >= (3, 11):
6+
from tomllib import load # noqa: TID251
7+
else:
8+
from tomli import load # noqa: TID251
9+
10+
__all__ = ("load",)

cibuildwheel/_compat/typing.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
5+
if sys.version_info < (3, 8):
6+
from typing_extensions import Final, Literal, OrderedDict, Protocol, TypedDict
7+
else:
8+
from typing import Final, Literal, OrderedDict, Protocol, TypedDict # noqa: TID251
9+
10+
if sys.version_info < (3, 11):
11+
from typing_extensions import NotRequired, assert_never
12+
else:
13+
from typing import NotRequired, assert_never # noqa: TID251
14+
15+
__all__ = (
16+
"Final",
17+
"Literal",
18+
"Protocol",
19+
"Protocol",
20+
"TypedDict",
21+
"OrderedDict",
22+
"assert_never",
23+
"NotRequired",
24+
)

cibuildwheel/architecture.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from collections.abc import Set
88
from enum import Enum
99

10-
from .typing import Final, Literal, PlatformName, assert_never
10+
from ._compat.typing import Final, Literal, assert_never
11+
from .typing import PlatformName
1112

1213
PRETTY_NAMES: Final = {"linux": "Linux", "macos": "macOS", "windows": "Windows"}
1314

0 commit comments

Comments
 (0)