Skip to content

Commit e8e9a42

Browse files
committed
Merge branch 'main' into events-in-python-2
2 parents fed5617 + c507028 commit e8e9a42

Some content is hidden

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

64 files changed

+1108
-588
lines changed

.github/workflows/build-manylinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575

7676
- name: Build and push Docker image
7777
if: steps.inspect.outcome == 'failure'
78-
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445
78+
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
7979
with:
8080
context: ${{ github.workspace }}/buildconfig/manylinux-build/docker_base
8181
file: ${{ github.workspace }}/buildconfig/manylinux-build/docker_base/Dockerfile-${{ matrix.arch }}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# this workflow generates C code coverage information from the unit test
2+
# suite. Note that for intrinsics, it only runs what gets compiled
3+
# and would naturally run. It also is limited to what can run in
4+
# a CI environment
5+
# IMPORTANT: binaries are not to be uploaded from this workflow!
6+
7+
name: Ubuntu coverage
8+
9+
# Run CI only when a release is created, on changes to main branch, or any PR
10+
# to main. Do not run CI on any other branch. Also, skip any non-source changes
11+
# from running on CI
12+
on:
13+
push:
14+
branches: main
15+
paths-ignore:
16+
- 'docs/**'
17+
- 'examples/**'
18+
- '.gitignore'
19+
- '*.rst'
20+
- '*.md'
21+
- '.github/workflows/*.yml'
22+
# gcov/lcov only gets C coverage
23+
- 'src_py/**'
24+
# re-include current file to not be excluded
25+
- '!.github/workflows/build-ubuntu-coverage.yml'
26+
27+
pull_request:
28+
branches: main
29+
paths-ignore:
30+
- 'docs/**'
31+
- 'examples/**'
32+
- '.gitignore'
33+
- '*.rst'
34+
- '*.md'
35+
- '.github/workflows/*.yml'
36+
# gcov/lcov only gets C coverage
37+
- 'src_py/**'
38+
# re-include current file to not be excluded
39+
- '!.github/workflows/build-ubuntu-coverage.yml'
40+
41+
concurrency:
42+
group: ${{ github.workflow }}-${{ github.ref }}-ubuntu-coverage
43+
cancel-in-progress: true
44+
45+
jobs:
46+
gen_coverage:
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
fail-fast: false # if a particular matrix build fails, don't skip the rest
50+
matrix:
51+
os: [ubuntu-22.04]
52+
53+
steps:
54+
- uses: actions/checkout@v4.1.7
55+
56+
- name: Install deps
57+
# install numpy from pip and not apt because the one from pip is newer,
58+
# and has typestubs
59+
# https://github.com/actions/runner-images/issues/7192
60+
# https://github.com/orgs/community/discussions/47863
61+
run: |
62+
sudo apt-get update --fix-missing
63+
sudo apt-get install lcov -y
64+
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev libportmidi-dev python3-dev -y
65+
pip3 install --upgrade pip
66+
pip3 install meson-python ninja cython "sphinx<=7.2.6" # because we are doing --no-build-isolation
67+
pip3 install numpy>=1.21.0
68+
69+
- name: Build with coverage hooks and install
70+
id: build
71+
run: |
72+
pip3 install -e . --no-build-isolation -Cbuild-dir=./.mesonpy-rel -Csetup-args=-Dcoverage=true
73+
74+
- name: Run tests
75+
env:
76+
SDL_VIDEODRIVER: "dummy"
77+
SDL_AUDIODRIVER: "disk"
78+
run: python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300
79+
80+
- name: Generate coverage
81+
id: gen-coverage
82+
# want to continue regardless of whether a test failed or not as long as the job wasn't cancelled
83+
if: ${{ steps.build.conclusion == 'success' && !cancelled() }}
84+
run: |
85+
lcov --capture --directory . --output-file ./coverage.info
86+
genhtml ./coverage.info --output-directory ./out
87+
88+
# We upload the generated files under github actions assets
89+
- name: Upload coverage html
90+
# want to continue only if the coverage generation was successful
91+
if: ${{ steps.gen-coverage.conclusion == 'success' && !cancelled() }}
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: pygame-wheels-coverage
95+
path: ./out

.github/workflows/release-gh-draft.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: echo "VER=${GITHUB_REF_NAME#'release/'}" >> $GITHUB_OUTPUT
6262

6363
- name: Generate release attestation
64-
uses: actions/attest-build-provenance@v1.4.0
64+
uses: actions/attest-build-provenance@v1.4.2
6565
with:
6666
subject-path: "pygame-wheels/*"
6767

buildconfig/stubs/gen_stubs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import pathlib
7+
import shutil
78
from typing import Any
89

910
import pygame.constants
@@ -51,6 +52,7 @@
5152
"system",
5253
"geometry",
5354
"window",
55+
"typing",
5456
]
5557

5658
# pygame classes that are autoimported into main namespace are kept in this dict
@@ -151,3 +153,8 @@ def get_all(mod: Any):
151153
for element in get_all(pygame.locals):
152154
constant_type = getattr(pygame.locals, element).__class__.__name__
153155
f.write(f"{element}: {constant_type}\n")
156+
157+
# copy typing.py to typing.pyi for type checkers
158+
typing_py_file = pathlib.Path(__file__).parent.parent.parent / "src_py" / "typing.py"
159+
typing_stub_file = pathlib.Path(__file__).parent / "pygame" / "typing.pyi"
160+
shutil.copyfile(typing_py_file, typing_stub_file)

buildconfig/stubs/mypy_allow_list.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# listed here are not checked by the mypy stubtest program
33
# This allowlist supports regex
44

5-
# This is not a real typestub file, it is used only in the typestubs to export
6-
# a few utility typestub definitions
7-
pygame\._common
8-
95
# cython files have this top level dunder
106
pygame\._sdl2\..*\.__test__
117

buildconfig/stubs/pygame/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from pygame import (
3838
system as system,
3939
geometry as geometry,
4040
window as window,
41+
typing as typing,
4142
)
4243

4344
from .rect import Rect as Rect, FRect as FRect
@@ -183,6 +184,9 @@ from .constants import (
183184
FINGERDOWN as FINGERDOWN,
184185
FINGERMOTION as FINGERMOTION,
185186
FINGERUP as FINGERUP,
187+
FLASH_BRIEFLY as FLASH_BRIEFLY,
188+
FLASH_CANCEL as FLASH_CANCEL,
189+
FLASH_UNTIL_FOCUSED as FLASH_UNTIL_FOCUSED,
186190
FONT_CENTER as FONT_CENTER,
187191
FONT_LEFT as FONT_LEFT,
188192
FONT_RIGHT as FONT_RIGHT,

buildconfig/stubs/pygame/_common.pyi

Lines changed: 0 additions & 120 deletions
This file was deleted.

buildconfig/stubs/pygame/_sdl2/video.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from pygame.rect import Rect
55
from pygame.surface import Surface
66
from pygame.window import Window as Window
77

8-
from .._common import ColorValue, RectValue, Coordinate
8+
from pygame.typing import ColorLike, RectLike, Coordinate
99

1010
WINDOWPOS_UNDEFINED: int
1111
WINDOWPOS_CENTERED: int
@@ -60,13 +60,13 @@ class Texture:
6060
@property
6161
def color(self) -> Color: ...
6262
@color.setter
63-
def color(self, value: ColorValue) -> None: ...
63+
def color(self, value: ColorLike) -> None: ...
6464

6565
def get_rect(self, **kwargs: Any) -> Rect: ...
6666
def draw(
6767
self,
68-
srcrect: Optional[RectValue] = None,
69-
dstrect: Optional[RectValue] = None,
68+
srcrect: Optional[RectLike] = None,
69+
dstrect: Optional[RectLike] = None,
7070
angle: float = 0.0,
7171
origin: Optional[Iterable[int]] = None,
7272
flip_x: bool = False,
@@ -99,17 +99,17 @@ class Texture:
9999
p3_mod: Iterable[int] = (255, 255, 255, 255),
100100
p4_mod: Iterable[int] = (255, 255, 255, 255),
101101
) -> None: ...
102-
def update(self, surface: Surface, area: Optional[RectValue] = None) -> None: ...
102+
def update(self, surface: Surface, area: Optional[RectLike] = None) -> None: ...
103103

104104
class Image:
105105
def __init__(
106106
self,
107107
texture_or_image: Union[Texture, Image],
108-
srcrect: Optional[RectValue] = None,
108+
srcrect: Optional[RectLike] = None,
109109
) -> None: ...
110110
def get_rect(self) -> Rect: ...
111111
def draw(
112-
self, srcrect: Optional[RectValue] = None, dstrect: Optional[RectValue] = None
112+
self, srcrect: Optional[RectLike] = None, dstrect: Optional[RectLike] = None
113113
) -> None: ...
114114
angle: float
115115
origin: Optional[Iterable[float]]
@@ -123,7 +123,7 @@ class Image:
123123
@property
124124
def color(self) -> Color: ...
125125
@color.setter
126-
def color(self, value: ColorValue) -> None: ...
126+
def color(self, value: ColorLike) -> None: ...
127127

128128
class Renderer:
129129
def __init__(
@@ -140,25 +140,25 @@ class Renderer:
140140
@property
141141
def draw_color(self) -> Color: ...
142142
@draw_color.setter
143-
def draw_color(self, value: ColorValue) -> None: ...
143+
def draw_color(self, value: ColorLike) -> None: ...
144144
def clear(self) -> None: ...
145145
def present(self) -> None: ...
146146
def get_viewport(self) -> Rect: ...
147-
def set_viewport(self, area: Optional[RectValue]) -> None: ...
147+
def set_viewport(self, area: Optional[RectLike]) -> None: ...
148148
logical_size: Iterable[int]
149149
scale: Iterable[float]
150150
target: Optional[Texture]
151151
def blit(
152152
self,
153153
source: Union[Texture, Image],
154-
dest: Optional[RectValue] = None,
155-
area: Optional[RectValue] = None,
154+
dest: Optional[RectLike] = None,
155+
area: Optional[RectLike] = None,
156156
special_flags: int = 0,
157157
) -> Rect: ...
158158
def draw_line(self, p1: Coordinate, p2: Coordinate) -> None: ...
159159
def draw_point(self, point: Coordinate) -> None: ...
160-
def draw_rect(self, rect: RectValue) -> None: ...
161-
def fill_rect(self, rect: RectValue) -> None: ...
160+
def draw_rect(self, rect: RectLike) -> None: ...
161+
def fill_rect(self, rect: RectLike) -> None: ...
162162
def draw_triangle(
163163
self, p1: Coordinate, p2: Coordinate, p3: Coordinate
164164
) -> None: ...
@@ -172,7 +172,7 @@ class Renderer:
172172
self, p1: Coordinate, p2: Coordinate, p3: Coordinate, p4: Coordinate
173173
) -> None: ...
174174
def to_surface(
175-
self, surface: Optional[Surface] = None, area: Optional[RectValue] = None
175+
self, surface: Optional[Surface] = None, area: Optional[RectLike] = None
176176
) -> Surface: ...
177177
@staticmethod
178178
def compose_custom_blend_mode(

buildconfig/stubs/pygame/camera.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import ABC, abstractmethod
22
from typing import List, Optional, Tuple, Union, Literal
33

4-
from ._common import IntCoordinate
4+
from pygame.typing import IntCoordinate
55

66
from pygame.surface import Surface
77

0 commit comments

Comments
 (0)