Skip to content

Commit 7cb57e8

Browse files
committed
Merge main
2 parents 5e02e19 + 500dce0 commit 7cb57e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1686
-1352
lines changed

.github/workflows/build-macos.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,40 +85,34 @@ jobs:
8585
# of these builds take roughly the same time
8686
include:
8787
- {
88-
name: "x86_64 (CPython 3.10 and above)",
88+
name: "x86_64 (CPython 3.9 - 3.12)",
8989
macarch: x86_64,
90-
# pattern matches any 2 digit number
91-
pyversions: "cp3[1-9][0-9]-*",
92-
cibw_platform: "macosx-10.11-x86_64"
90+
pyversions: "cp3{9,10,11,12}-*",
9391
}
9492

9593
- {
96-
name: "x86_64 (Python 3.7)",
94+
name: "x86_64 (CPython 3.7 and Python 3.8)",
9795
macarch: x86_64,
98-
pyversions: "?p37-*",
99-
cibw_platform: "macosx-10.11-x86_64"
96+
# CPython 3.7, CPython/PyPy 3.8
97+
pyversions: "cp37-* ?p38-*",
10098
}
10199

102100
- {
103-
name: "x86_64 (Python 3.8)",
101+
name: "x86_64 (PyPy 3.9 and 3.10)",
104102
macarch: x86_64,
105-
pyversions: "?p38-*",
106-
cibw_platform: "macosx-10.11-x86_64"
103+
pyversions: "pp39-* pp310-*",
107104
}
108105

109106
- {
110-
name: "x86_64 (Python 3.9)",
111-
macarch: x86_64,
112-
pyversions: "?p39-*",
113-
cibw_platform: "macosx-10.11-x86_64"
107+
name: "arm64 (CPython 3.8 - 3.10)",
108+
macarch: arm64,
109+
pyversions: "cp3{8,9,10}-*",
114110
}
115111

116112
- {
117-
name: "arm64 (CPython 3.8 and above)",
113+
name: "arm64 (CPython 3.11 - 3.12)",
118114
macarch: arm64,
119-
# pattern matches any number from 8 to 99
120-
pyversions: "cp3{8,9,[1-9][0-9]}-*",
121-
cibw_platform: "macosx-11.0-arm64"
115+
pyversions: "cp3{11,12}-*",
122116
}
123117

124118
env:
@@ -128,12 +122,21 @@ jobs:
128122
# also define environment variables needed for testing
129123
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
130124

131-
# Tell CIBW that the wheel should be for 10.11
125+
# Explicitly tell CIBW what the wheel arch deployment target should be
126+
# There seems to be no better way to set this than this env
127+
# We need this because our minimum is 10.11, different from default
128+
# of 10.9 on x86s
132129
# Related issue: https://github.com/pypa/cibuildwheel/issues/952
133-
_PYTHON_HOST_PLATFORM: ${{ matrix.cibw_platform }}
130+
_PYTHON_HOST_PLATFORM: ${{ matrix.macarch == 'x86_64' && 'macosx-10.11-x86_64' || 'macosx-11.0-arm64'}}
131+
132+
# Similarly, we need to tell CIBW that the wheel's linking steps
133+
# should be for 10.11 on x86
134+
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macarch == 'x86_64' && '10.11' || '11.0' }}
134135

135136
CIBW_BUILD: ${{ matrix.pyversions }}
136137

138+
CIBW_PRERELEASE_PYTHONS: True # for 3.12 testing
139+
137140
# Build arm64 and x86_64 wheels too on an Intel runner.
138141
# Note that the arm64 wheels cannot be tested on CI in this configuration
139142
CIBW_ARCHS: ${{ matrix.macarch }}
@@ -176,7 +179,7 @@ jobs:
176179
fail-on-cache-miss: true
177180

178181
- name: Build and test wheels
179-
uses: pypa/cibuildwheel@v2.13.1
182+
uses: pypa/cibuildwheel@v2.14.1
180183

181184
- uses: actions/upload-artifact@v3
182185
with:

.github/workflows/build-manylinux.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ jobs:
5454
# also define environment variables needed for testing
5555
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini PORTMIDI_INC_PORTTIME=1 SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
5656

57-
CIBW_BUILD: "cp3{[7-9],10,11}-* pp3[7-9]-*"
57+
CIBW_PRERELEASE_PYTHONS: True # for 3.12 testing
58+
59+
CIBW_BUILD: "cp3{[7-9],10,11,12}-* pp3{[8-9],10}-*"
5860
CIBW_ARCHS: ${{ matrix.arch }}
5961

6062
# skip musllinux for now
@@ -118,7 +120,7 @@ jobs:
118120
CIBW_MANYLINUX_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}
119121
CIBW_MANYLINUX_PYPY_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}
120122

121-
uses: pypa/cibuildwheel@v2.13.1
123+
uses: pypa/cibuildwheel@v2.14.1
122124

123125
# We upload the generated files under github actions assets
124126
- name: Upload dist

.github/workflows/build-windows.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ jobs:
4343
fail-fast: false # if a particular matrix build fails, don't skip the rest
4444
matrix:
4545
include:
46+
- {
47+
name: "CPython 3.12 (64 bit)",
48+
winarch: AMD64,
49+
msvc-dev-arch: x86_amd64,
50+
pyversions: "cp312-*"
51+
}
4652
- {
4753
name: "CPython 3.11 (64 bit)",
4854
winarch: AMD64,
@@ -73,6 +79,12 @@ jobs:
7379
msvc-dev-arch: x86_amd64,
7480
pyversions: "cp37-*"
7581
}
82+
- {
83+
name: "CPython 3.12 (32 bit)",
84+
winarch: x86,
85+
msvc-dev-arch: x86,
86+
pyversions: "cp312-win32*"
87+
}
7688
- {
7789
name: "CPython 3.11 (32 bit)",
7890
winarch: x86,
@@ -103,12 +115,6 @@ jobs:
103115
msvc-dev-arch: x86,
104116
pyversions: "cp37-win32"
105117
}
106-
- {
107-
name: "Pypy 3.7",
108-
winarch: AMD64,
109-
msvc-dev-arch: x86_amd64,
110-
pyversions: "pp37-*"
111-
}
112118
- {
113119
name: "Pypy 3.8",
114120
winarch: AMD64,
@@ -121,6 +127,12 @@ jobs:
121127
msvc-dev-arch: x86_amd64,
122128
pyversions: "pp39-*"
123129
}
130+
- {
131+
name: "Pypy 3.10",
132+
winarch: AMD64,
133+
msvc-dev-arch: x86_amd64,
134+
pyversions: "pp310-*"
135+
}
124136

125137

126138
env:
@@ -129,6 +141,8 @@ jobs:
129141
# also define environment variables needed for testing
130142
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
131143

144+
CIBW_PRERELEASE_PYTHONS: True # for 3.12 testing
145+
132146
CIBW_BUILD: ${{ matrix.pyversions }}
133147
CIBW_ARCHS: ${{ matrix.winarch }}
134148

@@ -158,7 +172,7 @@ jobs:
158172
set MSSdk=1
159173
python -m pip install setuptools wheel requests numpy Sphinx
160174
python setup.py docs
161-
python -m pip --disable-pip-version-check install cibuildwheel==2.12.0
175+
python -m pip --disable-pip-version-check install cibuildwheel==2.14.1
162176
python -m cibuildwheel --output-dir wheelhouse
163177
164178
- uses: actions/upload-artifact@v3

buildconfig/download_win_prebuilt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def get_urls(x86=True, x64=True):
7878
url_sha1 = []
7979
url_sha1.extend([
8080
[
81-
'https://github.com/libsdl-org/SDL/releases/download/release-2.26.4/SDL2-devel-2.26.4-VC.zip',
82-
'0dea77fd5ead8c1a2134af3fc256578327e25879',
81+
'https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-devel-2.26.5-VC.zip',
82+
'f040c352af677161200ec07463efe8d1325135e4',
8383
],
8484
[
8585
'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.5-VC.zip',
@@ -234,12 +234,12 @@ def copy(src, dst):
234234
copy(
235235
os.path.join(
236236
temp_dir,
237-
'SDL2-devel-2.26.4-VC/SDL2-2.26.4'
237+
'SDL2-devel-2.26.5-VC/SDL2-2.26.5'
238238
),
239239
os.path.join(
240240
move_to_dir,
241241
prebuilt_dir,
242-
'SDL2-2.26.4'
242+
'SDL2-2.26.5'
243243
)
244244
)
245245

buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e -x
33

44
cd $(dirname `readlink -f "$0"`)
55

6-
SDL2="SDL2-2.26.4"
6+
SDL2="SDL2-2.26.5"
77
IMG2="SDL2_image-2.0.5"
88
TTF2="SDL2_ttf-2.20.2"
99
MIX2="SDL2_mixer-2.6.2"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
138f52a23d796803c450722c8a4db8226214522e99f1e5ae657e2b28eb45abf0c81c9c3df9ab16f1a07d59722ed9415d64dd04332ff040cdfbbc0329f0d05ce4 SDL2-2.26.4.tar.gz
1+
0f37b443950bc89c3f3add2fc9a9970f42b47e933c106a1d676d1715c520125d5725ffcb9ff85bcf66ac3ff78d9d43d994f9c1935b7c0fd7951e10e251936bcc SDL2-2.26.5.tar.gz
22
77e743d3f32707e015b290c1379ae3c7d7a3fe265995713267f0d0ec6517de4808f0de9890b5ab28445941af5bc9fbff346620629e0d7d7e9f365262cab05ee7 SDL2_image-2.0.5.tar.gz
33
16baa9d8b345bf0224538cbfb2ae9fc5d3deea2b454f41a98006c938fe7a65d5a8c84e28a76f98a4dd971c4fe5cf0219d8bf73331cf11f2702e01600eb197658 SDL2_mixer-2.6.2.tar.gz
44
b54e93b100712e3764cd80d4e4b16cd4c2a6853620f675941a4214320b0ee29a583d57ad56cd5fdb5c7a32d7615cbf43bc3fa55337b01623cee7219ebb43667c SDL2_ttf-2.20.2.tar.gz
Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,104 @@
11
from os import PathLike
2-
from typing import IO, Callable, Sequence, Tuple, Union
2+
from typing import IO, Callable, Tuple, Union, TypeVar
33

4-
from typing_extensions import Literal as Literal
4+
from typing_extensions import Literal as Literal, SupportsIndex as SupportsIndex
55
from typing_extensions import Protocol
66

7-
from pygame.color import Color
8-
from pygame.math import Vector2
9-
from pygame.rect import Rect, FRect
10-
117
# For functions that take a file name
128
AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]]
139

1410
# Most pygame functions that take a file argument should be able to handle
1511
# a FileArg type
1612
FileArg = Union[AnyPath, IO[bytes], IO[str]]
1713

18-
Coordinate = Union[Tuple[float, float], Sequence[float], Vector2]
14+
_T = TypeVar("_T", covariant=True)
15+
16+
class Sequence(Protocol[_T]):
17+
"""
18+
This is different from the standard python 'Sequence' abc. This is used in places
19+
where only __getitem__ and __len__ is actually needed (basically almost all places
20+
where a sequence is used). The standard 'Sequence' abc has some extra methods.
21+
"""
22+
def __getitem__(self, __i: SupportsIndex) -> _T: ...
23+
def __len__(self) -> int: ...
24+
25+
# Right now, it isn't possible to annotate sizes (popular tools don't support it) but
26+
# when it is, the below types should be appropriately annotated
27+
28+
# Yes, float. The reason being, pygame handles float without erroring in a lot of places
29+
# where a coordinate is expected (usually by rounding to int).
30+
# Also, 'Union[int, float] == float'
31+
Coordinate = Sequence[float]
32+
33+
# This is used in places where ints are strictly required
34+
IntCoordinate = Sequence[int]
1935

20-
# This typehint is used when a function would return an RGBA tuble
36+
# This typehint is used when a function would return an RGBA tuple
2137
RGBAOutput = Tuple[int, int, int, int]
22-
ColorValue = Union[Color, int, str, Tuple[int, int, int], RGBAOutput, Sequence[int]]
23-
24-
_CanBeRect = Union[
25-
Rect,
26-
FRect,
27-
Tuple[int, int, int, int],
28-
Tuple[float, float, float, float],
29-
Tuple[Coordinate, Coordinate],
30-
Sequence[int],
31-
Sequence[float],
32-
Sequence[Coordinate],
33-
]
38+
ColorValue = Union[int, str, Sequence[int]]
39+
40+
_CanBeRect = Sequence[Union[float, Coordinate]]
3441

3542
class _HasRectAttribute(Protocol):
3643
# An object that has a rect attribute that is either a rect, or a function
3744
# that returns a rect confirms to the rect protocol
3845
rect: Union[RectValue, Callable[[], RectValue]]
3946

4047
RectValue = Union[_CanBeRect, _HasRectAttribute]
48+
49+
"""
50+
# testing code
51+
def a(b: Coordinate):
52+
b[0]
53+
b[1]
54+
len(b)
55+
e1, e2 = b
56+
for i in b:
57+
i -= 1
58+
59+
60+
import numpy
61+
from pygame import Vector2
62+
63+
class MyAmoger:
64+
def __init__(self):
65+
pass
66+
67+
def __getitem__(self, index):
68+
if index not in (0, 1):
69+
raise IndexError()
70+
71+
return 42 if index else 69
72+
73+
def __len__(self):
74+
return 2
75+
76+
77+
# should pass
78+
a([1, 2])
79+
a([4.2, 5.2])
80+
a((1, 2))
81+
a((1.4, 2.8))
82+
a(MyAmoger())
83+
a(range(2, 4)) # yes, range object is a 'Sequence'
84+
a(numpy.array([1.3, 2.1]))
85+
a(b"ab") # weird but this actually works in code (this represents (97, 98) btw)
86+
a(bytearray([1, 2]))
87+
a(Vector2())
88+
89+
print("Done testing the passes!")
90+
91+
# should technically error, but right now we can't annotate sizes so they pass on
92+
# type testing
93+
a([1, 2, 3])
94+
a([4.2, 5.2, 2, 4])
95+
a((1,))
96+
a(numpy.array([1.3, 2.1, 4.2]))
97+
98+
# all of the below should always error
99+
a({})
100+
a({1: 2})
101+
a("abc")
102+
a({1, 2})
103+
104+
"""

buildconfig/stubs/pygame/_sdl2/video.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Window:
6666
def minimize(self) -> None: ...
6767
resizable: bool
6868
borderless: bool
69+
always_on_top: bool
6970
def set_icon(self, surface: Surface) -> None: ...
7071
id: int
7172
size: Iterable[int]

buildconfig/stubs/pygame/_window.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Window:
2828
title: str
2929
resizable: bool
3030
borderless: bool
31+
always_on_top: bool
3132
relative_mouse: bool
3233
id: int
3334
size: Iterable[int]

buildconfig/stubs/pygame/camera.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from abc import ABC, abstractmethod
2-
from typing import List, Optional, Sequence, Tuple, Union
2+
from typing import List, Optional, Tuple, Union
3+
4+
from ._common import IntCoordinate
35

46
from pygame.surface import Surface
57

@@ -31,7 +33,7 @@ class Camera(AbstractCamera):
3133
def __init__(
3234
self,
3335
device: Union[str, int] = 0,
34-
size: Union[Tuple[int, int], Sequence[int]] = (640, 480),
36+
size: IntCoordinate = (640, 480),
3537
format: str = "RGB",
3638
) -> None: ...
3739
def start(self) -> None: ...

0 commit comments

Comments
 (0)