4
4
This file is added to the PYTHONPATH in the test runner at bin/run_test.py.
5
5
"""
6
6
7
+ import functools
7
8
import os
8
9
import platform as pm
9
10
import subprocess
10
11
import sys
11
- from collections .abc import Mapping , Sequence
12
+ from collections .abc import Callable , Generator , Mapping , Sequence
12
13
from pathlib import Path
13
14
from tempfile import TemporaryDirectory
14
- from typing import Any , Final
15
+ from typing import Any , Final , ParamSpec , TypeVar
15
16
16
17
import pytest
17
18
@@ -151,6 +152,19 @@ def _floor_macosx(*args: str) -> str:
151
152
return max (args , key = lambda x : tuple (map (int , x .split ("." ))))
152
153
153
154
155
+ P = ParamSpec ("P" )
156
+ R = TypeVar ("R" )
157
+
158
+
159
+ def _listify (func : Callable [P , Generator [R , None , None ]]) -> Callable [P , list [R ]]:
160
+ @functools .wraps (func )
161
+ def listify_return (* args : P .args , ** kwargs : P .kwargs ) -> list [R ]:
162
+ return list (func (* args , ** kwargs ))
163
+
164
+ return listify_return
165
+
166
+
167
+ @_listify
154
168
def expected_wheels (
155
169
package_name : str ,
156
170
package_version : str ,
@@ -162,9 +176,9 @@ def expected_wheels(
162
176
include_universal2 : bool = False ,
163
177
single_python : bool = False ,
164
178
single_arch : bool = False ,
165
- ) -> list [str ]:
179
+ ) -> Generator [str , None , None ]:
166
180
"""
167
- Returns a list of expected wheels from a run of cibuildwheel.
181
+ Returns the expected wheels from a run of cibuildwheel.
168
182
"""
169
183
# per PEP 425 (https://www.python.org/dev/peps/pep-0425/), wheel files shall have name of the form
170
184
# {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl
@@ -240,13 +254,12 @@ def expected_wheels(
240
254
)
241
255
]
242
256
243
- wheels : list [str ] = []
244
-
245
257
if platform == "pyodide" :
246
258
assert len (python_abi_tags ) == 1
247
259
python_abi_tag = python_abi_tags [0 ]
248
260
platform_tag = "pyodide_2024_0_wasm32"
249
- return [f"{ package_name } -{ package_version } -{ python_abi_tag } -{ platform_tag } .whl" ]
261
+ yield f"{ package_name } -{ package_version } -{ python_abi_tag } -{ platform_tag } .whl"
262
+ return
250
263
251
264
for python_abi_tag in python_abi_tags :
252
265
platform_tags = []
@@ -317,12 +330,8 @@ def expected_wheels(
317
330
msg = f"Unsupported platform { platform !r} "
318
331
raise Exception (msg )
319
332
320
- wheels .extend (
321
- f"{ package_name } -{ package_version } -{ python_abi_tag } -{ platform_tag } .whl"
322
- for platform_tag in platform_tags
323
- )
324
-
325
- return wheels
333
+ for platform_tag in platform_tags :
334
+ yield f"{ package_name } -{ package_version } -{ python_abi_tag } -{ platform_tag } .whl"
326
335
327
336
328
337
def get_macos_version () -> tuple [int , int ]:
0 commit comments