1
1
from __future__ import annotations
2
2
3
3
import subprocess
4
+ import sys
4
5
import textwrap
5
6
6
7
import pytest
14
15
# is the same one as is currently running.
15
16
with open("text_info.txt") as f:
16
17
stored_text = f.read()
17
-
18
18
print("## stored text: " + stored_text)
19
- assert stored_text == "sample text 123"
19
+ parts = stored_text.split("+")
20
+ assert len(parts) == 3
21
+ assert parts[0] == "cpython"
22
+ if sys.implementation.name == "cpython":
23
+ assert sys.hexversion != int(parts[1])
24
+ assert parts[2] == "sample text 123"
20
25
"""
21
26
)
22
27
)
@@ -29,22 +34,38 @@ def test(tmp_path):
29
34
with (project_dir / "text_info.txt" ).open (mode = "w" ) as ff :
30
35
print ("dummy text" , file = ff )
31
36
37
+ # we want to limit the number of builds to speed-up tests
38
+ builds = ["pp310" ] # always one version of PyPy
39
+ if utils .platform == "linux" :
40
+ # Linux uses cp38 as a global python
41
+ builds .append ("cp312" )
42
+ else :
43
+ # use a CPython version that's not running cibuildwheel
44
+ for minor in range (12 , 8 , - 1 ):
45
+ if (3 , minor ) != sys .version_info [:2 ]:
46
+ builds .append (f"cp3{ minor } " )
47
+ break
48
+ assert len (builds ) == 2
49
+
32
50
# build the wheels
33
- before_all_command = '''python -c "import os;open('{project}/text_info.txt', 'w').write(' sample text '+os.environ.get('TEST_VAL', ''))"'''
51
+ before_all_command = '''python -ISc "import os, sys ;open('{project}/text_info.txt', 'w').write(f'{sys.implementation.name}+{sys.hexversion}+ sample text '+os.environ.get('TEST_VAL', ''))"'''
34
52
actual_wheels = utils .cibuildwheel_run (
35
53
project_dir ,
36
54
add_env = {
55
+ "CIBW_BUILD" : " " .join (f"{ build } -*" for build in builds ),
37
56
# write python version information to a temporary file, this is
38
57
# checked in setup.py
39
58
"CIBW_BEFORE_ALL" : before_all_command ,
40
- "CIBW_BEFORE_ALL_LINUX" : f'{ before_all_command } && python -c "import sys; assert sys.version_info >= (3, 6)"' ,
59
+ "CIBW_BEFORE_ALL_LINUX" : f'{ before_all_command } && python -ISc "import sys; assert sys.version_info >= (3, 6)"' ,
41
60
"CIBW_ENVIRONMENT" : "TEST_VAL='123'" ,
42
61
},
43
62
)
44
63
45
64
# also check that we got the right wheels
46
65
(project_dir / "text_info.txt" ).unlink ()
47
- expected_wheels = utils .expected_wheels ("spam" , "0.1.0" )
66
+ expected_wheels = [
67
+ w for w in utils .expected_wheels ("spam" , "0.1.0" ) if any (build in w for build in builds )
68
+ ]
48
69
assert set (actual_wheels ) == set (expected_wheels )
49
70
50
71
0 commit comments